-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to start ember serve on https #3550
Merged
stefanpenner
merged 6 commits into
ember-cli:master
from
drogus:allow-to-serve-app-on-ssl
May 20, 2015
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
78486e9
Add ability to start ember serve on https
drogus d82850d
use new lodash require
stefanpenner 61fefb8
fix missing comma
stefanpenner 4291fc5
use a promise in the test
stefanpenner 6eadb5e
Fix tests
drogus 76162bc
Extract https server creation to separate function
drogus File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
var path = require('path'); | ||
var EventEmitter = require('events').EventEmitter; | ||
var chalk = require('chalk'); | ||
var fs = require('fs'); | ||
var debounce = require('lodash/function/debounce'); | ||
var mapSeries = require('promise-map-series'); | ||
var Promise = require('../../ext/promise'); | ||
|
@@ -16,6 +17,7 @@ module.exports = Task.extend({ | |
this.emitter = new EventEmitter(); | ||
this.express = this.express || require('express'); | ||
this.http = this.http || require('http'); | ||
this.https = this.https || require('https'); | ||
|
||
var serverRestartDelayTime = this.serverRestartDelayTime || 100; | ||
this.scheduleServerRestart = debounce(function(){ | ||
|
@@ -36,7 +38,21 @@ module.exports = Task.extend({ | |
}, | ||
|
||
setupHttpServer: function() { | ||
this.httpServer = this.http.createServer(this.app); | ||
if (this.startOptions.ssl) { | ||
if(!fs.existsSync(this.startOptions.sslKey)) { | ||
throw new TypeError('Ssl key couldn\'t be found in "' + this.startOptions.sslKey + '", please provide a path to an existing ssl key file with --ssl-key'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
if(!fs.existsSync(this.startOptions.sslKey)) { | ||
throw new TypeError('Ssl certificate couldn\'t be found in "' + this.startOptions.sslCert + '", please provide a path to an existing ssl certificate file with --ssl-cert'); | ||
} | ||
var options = { | ||
key: fs.readFileSync(this.startOptions.sslKey), | ||
cert: fs.readFileSync(this.startOptions.sslCert) | ||
}; | ||
this.httpServer = this.https.createServer(options, this.app); | ||
} else { | ||
this.httpServer = this.http.createServer(this.app); | ||
} | ||
|
||
// We have to keep track of sockets so that we can close them | ||
// when we need to restart. | ||
|
@@ -105,7 +121,7 @@ module.exports = Task.extend({ | |
.then(function () { | ||
var baseURL = cleanBaseURL(options.baseURL); | ||
|
||
options.ui.writeLine('Serving on http://' + this.displayHost(options.host) + ':' + options.port + baseURL); | ||
options.ui.writeLine('Serving on http' + (options.ssl ? 's' : '') + '://' + this.displayHost(options.host) + ':' + options.port + baseURL); | ||
}.bind(this)); | ||
}, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDLjCCAhYCCQClpT57IEXr0zANBgkqhkiG9w0BAQUFADBZMQswCQYDVQQGEwJB | ||
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0 | ||
cyBQdHkgTHRkMRIwEAYDVQQDEwlsb2NhbGhvc3QwHhcNMTUwMzE2MTk1NDIyWhcN | ||
NDIwODAxMTk1NDIyWjBZMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0 | ||
ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRIwEAYDVQQDEwls | ||
b2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqr6SuXrYh | ||
T4cY2l+EvbxeBthuWIXNxGO50w3GfmqlVFG24Nl5+cpDWf0fr8d7eilqW6O05PTW | ||
ZTKNPaLjf1AQ7HAm2Ql02Q6EWn0BUa9y8njhwdhP+QgcBphmkoSNWQ1+SQEXSIaF | ||
91fq36/PGY+ZzqY31+OdyZhqEWDhaAdXlzjCZKTMBFijUo2GljJGQ47wpNSaXM1I | ||
kvG1WAbEBB9gbwbbEy94bx23G8AIkzft5qUb8Trjzz4PsAc6RUdULYqmOrKBcfP2 | ||
i9pCkXtnpi9ESFSuC3T5Qycl4AcyowOvyln+DXI0YrVmqpJxtgP0iu42fZ7V+X6S | ||
8B1gz4py9D8BAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAISek/NhWEd3EtTgJO8P | ||
vT24abyUFxcIF6+6a4DHE6DylpRJ8Aw5xB4ebVBGw6xREbqsCvkDZlosvu0zJBL3 | ||
CabzQLB//JyQJ5kg+hqBeB3gk6dzzOmdbdP2Xj42Hvf72e+xO7eI9QPpAz3Sbx1g | ||
plEBUFyQ3ZdX5SrOVGJWw9UeUO2DewETqw2ldRFd9H/Reeai63sY+8g8fXLPh2DW | ||
6mU+5YclJpKZJmtiUbdpwoKuXJLtjAZ0T5JHSIY9Ddz+H3B8270EaDDFaTkwYs/6 | ||
ARcPqIRGcEmsvw+9JvcBHiaDc4bKfOk+fK9Styjbo07Hzy7UpIUXm73Wj0HwFaHf | ||
A74= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN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YGY2S9JR+bUjFZQWl7JDbgCiVN | ||
C+n7ld/Gebm2V3rZfqMkUSdDh9QfBbF2iJmzVicCgYA/ZzcqF63ju+athO9Bvybn | ||
FuXK1smcFakJ+HM64hDPXV+XeNu8PUxKxd47vOslCVsZHgBuUKzn61QHyP5zGnGk | ||
QLJdk44zn2H4fffm7OYPKFdQpMMxzY893mEv8Xtpz5wHIRY4jrHUjo17wjVsiky1 | ||
Vm70sb6mOEE8oG433QI6AwKBgBR7dPoAxLhZWvIyLpdT0BqIXEPUwsOIwQLwXUYu | ||
6+6MuB3e5Ps8BXLW+PMTBGhv4uhdFQlqSq3FE6EFE55z7lcoz5XXviYv01GSTpdq | ||
G+CncBzd2s7/HGXZPqMbI/XLJ3vNV/XiHV9u9093/Lg8LrwxlShVH/x1Hk1UCccr | ||
YpLXAoGBAKYpmgybQrn51IPFHo66fvu/TR4G24OISORzhMq8wrNuIeWMaz5sjcv+ | ||
mNMoeQjHYYcySo9x9yJcMHMy2VoHLVxJnlsw44ujhJcQ+ZvBdNPqvuRqXXfYEJNB | ||
l9ZULBlC/ChhqvCJ0KUEcKBeDFXpXyBqaGxfB24xKm73sWlhFL1d | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this should be moved to a function (for cleanup, and to make it obvious what is part of the SSL setup)