{"id":25483698,"url":"https://github.com/rahatool/self-cert","last_synced_at":"2025-11-07T07:30:22.471Z","repository":{"id":243117354,"uuid":"811466617","full_name":"rahatool/self-cert","owner":"rahatool","description":"This is a simple library for generating a self-signed x509 key-pair and certificate.","archived":false,"fork":false,"pushed_at":"2024-06-06T21:00:33.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"development","last_synced_at":"2024-06-07T20:57:23.304Z","etag":null,"topics":["certificate","pem","self-signed","signing-certificate","ssl","tls","x509"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rahatool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-06T16:44:54.000Z","updated_at":"2024-06-06T21:00:36.000Z","dependencies_parsed_at":"2024-06-06T21:08:21.326Z","dependency_job_id":null,"html_url":"https://github.com/rahatool/self-cert","commit_stats":null,"previous_names":["rahatool/self-cert"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahatool%2Fself-cert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahatool%2Fself-cert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahatool%2Fself-cert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahatool%2Fself-cert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahatool","download_url":"https://codeload.github.com/rahatool/self-cert/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239520911,"owners_count":19652776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["certificate","pem","self-signed","signing-certificate","ssl","tls","x509"],"created_at":"2025-02-18T17:47:39.721Z","updated_at":"2025-11-07T07:30:22.419Z","avatar_url":"https://github.com/rahatool.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# self-cert\nThis is a simple library to generate a self-signed x509 key-pair and certificate.\n\n# Installation\n## CDN\nImport library from the ESM.SH CDN for fast and easy setup:\n```javascript\nimport {create} from \"//esm.sh/gh/rahatool/self-cert\";\n```\n## NPM registry\nUse the package manager npm to install self-cert.\n```shell\n$ npm install github:rahatool/self-cert\n```\n\n# Usage\n## Self-signed Certificate\n1) Create a [new project](https://docs.npmjs.com/cli/v7/commands/npm-init) with the entry point \"index.mjs\".\n2) Add the project dependency by `npm i github:rahatool/self-cert`.\n3) Put the following script in file \"index.mjs\".\n```javascript\nimport {create as createCertificate} from '@raha.group/self-cert';\nimport fs from 'fs/promises';\nimport os from 'os';\n\nlet hosts = [];\nfor (let networkInterface of Object.values(os.networkInterfaces())) {\n\tfor (let assignedNetworkAddress of networkInterface) {\n\t\thosts.push(assignedNetworkAddress.address);\n\t}\n}\n\nlet certificate = createCertificate({\n\tdomains: [ // List the hostnames (including wildcards) on your origin that the certificate should protect.\n\t\t'localhost',\n\t\t'*.local', // wildcards\n\t\t...hosts\n\t],\n\texpires: new Date(2025, 1),\n\t/*\n\tattributes: {\n\t\tcommonName: domains[0],\n\t\tcountryName: 'IR',\n\t\tstateName: 'Isfahan',\n\t\tlocality: 'Isfahan',\n\t\torganizationName: 'None',\n\t},\n\tkeySize: 2048,\n\t*/\n});\nawait fs.writeFile('privateKey.pem', certificate.privateKey);\nawait fs.writeFile('publicKey.pem', certificate.publicKey);\nawait fs.writeFile('certificate.pem', certificate.certificate);\n```\n\n## Basic HTTPS\nHere is an example of generating an SSL key/cert on the fly and running an HTTPS server on port 443. Use https://localhost:443 to access the created server.\n```javascript\nimport {create as createCertificate} from '@raha.group/self-cert';\nimport https from 'https';\n\nlet certificate = createCertificate({\n\tdomains: ['localhost'],\n});\nhttps.createServer({key: certificate.privateKey, cert: certificate.certificate}, function(request, response) {\n\tresponse.end('Hello World ~_^');\n}).listen(443);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahatool%2Fself-cert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahatool%2Fself-cert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahatool%2Fself-cert/lists"}