{"id":13749523,"url":"https://github.com/strongloop/loopback-example-ssl","last_synced_at":"2025-05-09T12:33:10.690Z","repository":{"id":13721562,"uuid":"16415712","full_name":"strongloop/loopback-example-ssl","owner":"strongloop","description":"An example to demonstrate how to set up SSL for LoopBack applications","archived":true,"fork":false,"pushed_at":"2020-03-05T14:56:28.000Z","size":49,"stargazers_count":69,"open_issues_count":0,"forks_count":31,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-08-04T07:03:32.605Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strongloop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2014-01-31T17:57:34.000Z","updated_at":"2023-01-28T14:57:57.000Z","dependencies_parsed_at":"2022-07-30T16:08:55.242Z","dependency_job_id":null,"html_url":"https://github.com/strongloop/loopback-example-ssl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-ssl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-ssl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-ssl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-ssl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strongloop","download_url":"https://codeload.github.com/strongloop/loopback-example-ssl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224863107,"owners_count":17382279,"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":[],"created_at":"2024-08-03T07:01:04.262Z","updated_at":"2024-11-16T00:30:47.170Z","avatar_url":"https://github.com/strongloop.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# loopback-example-ssl\n\n**⚠️ This LoopBack 3 example project is no longer maintained. Please refer to [LoopBack 4 Examples](https://loopback.io/doc/en/lb4/Examples.html) instead. ⚠️**\n\nAn example to demonstrate how to set up SSL for LoopBack applications so you can call the REST APIs using HTTPS.\n\n## Generate your own SSL certificate\n\n```sh\n  $ cd loopback-example-ssl/server/private\n  $ openssl genrsa -out privatekey.pem 1024\n  $ openssl req -new -key privatekey.pem -out certrequest.csr\n  $ openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem\n```\n\n## Load the SSL certificate\n\nIn `ssl-config.js`:\n\n```js\nvar path = require('path'),\nfs = require(\"fs\");\nexports.privateKey = fs.readFileSync(path.join(__dirname, './private/privatekey.pem')).toString();\nexports.certificate = fs.readFileSync(path.join(__dirname, './private/certificate.pem')).toString();\n```\n\n## Create the HTTPS server\n\nThe code is in `server/server.js`:\n\n```js\n\nvar https = require('https');\nvar sslConfig = require('./ssl-config');\n\n...\n\nvar options = {\n  key: sslConfig.privateKey,\n  cert: sslConfig.certificate\n};\n...\n\nserver.listen(app.get('port'), function() {\n    var baseUrl = (httpOnly? 'http://' : 'https://') + app.get('host') + ':' + app.get('port');\n    app.emit('started', baseUrl);\n    console.log('LoopBack server listening @ %s%s', baseUrl, '/');\n});\nreturn server;\n```\n\n## Start the application\n```sh\n  $  node ./server/server.js\n```\n## Open the API explorer\n\n[https://localhost:3000/explorer](https://localhost:3000/explorer)\n\n## References\n\n1. [http://nodejs.org/api/https.html](http://nodejs.org/api/https.html)\n\n---\n\n[More LoopBack examples](https://loopback.io/doc/en/lb3/Tutorials-and-examples.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Floopback-example-ssl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrongloop%2Floopback-example-ssl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Floopback-example-ssl/lists"}