-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
} | ||
|
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.