-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
tls: copy client CAs and cert store on CertCb #3537
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,8 @@ template class SSLWrap<TLSWrap>; | |
template void SSLWrap<TLSWrap>::AddMethods(Environment* env, | ||
Local<FunctionTemplate> t); | ||
template void SSLWrap<TLSWrap>::InitNPN(SecureContext* sc); | ||
template void SSLWrap<TLSWrap>::SetSNIContext(SecureContext* sc); | ||
template int SSLWrap<TLSWrap>::SetCACerts(SecureContext* sc); | ||
template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback( | ||
SSL* s, | ||
unsigned char* key, | ||
|
@@ -2264,6 +2266,8 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) { | |
rv = SSL_use_PrivateKey(w->ssl_, pkey); | ||
if (rv && chain != nullptr) | ||
rv = SSL_set1_chain(w->ssl_, chain); | ||
if (rv) | ||
rv = w->SetCACerts(sc); | ||
if (!rv) { | ||
unsigned long err = ERR_get_error(); | ||
if (!err) | ||
|
@@ -2314,6 +2318,28 @@ void SSLWrap<Base>::DestroySSL() { | |
} | ||
|
||
|
||
template <class Base> | ||
void SSLWrap<Base>::SetSNIContext(SecureContext* sc) { | ||
InitNPN(sc); | ||
SSL_set_SSL_CTX(ssl_, sc->ctx_); | ||
|
||
SetCACerts(sc); | ||
} | ||
|
||
|
||
template <class Base> | ||
int SSLWrap<Base>::SetCACerts(SecureContext* sc) { | ||
int err = SSL_set1_verify_cert_store(ssl_, SSL_CTX_get_cert_store(sc->ctx_)); | ||
if (err != 1) | ||
return err; | ||
|
||
STACK_OF(X509_NAME)* list = SSL_dup_CA_list( | ||
SSL_CTX_get_client_CA_list(sc->ctx_)); | ||
SSL_set_client_CA_list(ssl_, list); | ||
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. Can you add a comment explaining that 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. ACK. |
||
return 1; | ||
} | ||
|
||
|
||
void Connection::OnClientHelloParseEnd(void* arg) { | ||
Connection* conn = static_cast<Connection*>(arg); | ||
|
||
|
@@ -2627,8 +2653,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) { | |
if (secure_context_constructor_template->HasInstance(ret)) { | ||
conn->sni_context_.Reset(env->isolate(), ret); | ||
SecureContext* sc = Unwrap<SecureContext>(ret.As<Object>()); | ||
InitNPN(sc); | ||
SSL_set_SSL_CTX(s, sc->ctx_); | ||
conn->SetSNIContext(sc); | ||
} else { | ||
return SSL_TLSEXT_ERR_NOACK; | ||
} | ||
|
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
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.
Maybe
CHECK_EQ(sc->ctx_, SSL_set_SSL_CTX(ssl_, sc->ctx_));
? I don't thinkSSL_set_SSL_CTX
can actually fail as such but a little paranoia won't hurt.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 the result is just for convenience, not for return value checking.
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.
Then it won't hurt to check it. CHECK_EQ is cheap.
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.
ACK.