This repository has been archived by the owner on Jul 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
http2: specify default TLS options for http2 client connection. #61
Closed
Conversation
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
Had a different approach in mind for fixing this: diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index 6afc87e6f7..052513289f 100755
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -1077,6 +1077,7 @@ function initializeOptions(options) {
options = options || {};
if (typeof options !== 'object')
throw new TypeError('options must be an object');
+ options = Object.create(options);
options.allowHalfOpen = true;
options.settings = options.settings || {};
if (typeof options.settings !== 'object')
@@ -1084,10 +1085,12 @@ function initializeOptions(options) {
return options;
}
-function initializeTLSOptions(options) {
+function initializeTLSOptions(options, host) {
options = initializeOptions(options);
options.ALPNProtocols = ['hc', 'h2'];
options.NPNProtocols = ['hc', 'h2'];
+ if (host !== undefined)
+ options.servername = host;
return options;
}
@@ -1235,7 +1238,7 @@ function connect(authority, options, listener) {
socket = net.connect(port, host);
break;
case 'https:':
- socket = tls.connect(port, host, options);
+ socket = tls.connect(port, host, initializeTLSOptions(options, host));
break;
default:
throw new TypeError(`protocol "${protocol}" in unsupported.`);
james@ubuntu:~/node/http2-jasnell$ This allows us to have a central place for setting the TLS options for both server and client. |
This verifies to send the server name and ALPN protocols by default.
Thank you for the review! Added a test case, and fixed the client code for your latter suggestion. |
By the way -- where does the ALPN name |
I think it's an old pre-standard value. One of the browser impls was using it. Whether or not we need to keep it remains to be seen |
Removed the count, thank you for the background info. |
@mcollina ... ping |
LGTM |
Landed! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
fixes: #59