diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 8af318791cc49a..2fb6e887d1db9f 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -521,10 +521,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx, // the CA certificates. int r; - if (ctx->extra_certs != nullptr) { - sk_X509_pop_free(ctx->extra_certs, X509_free); - ctx->extra_certs = nullptr; - } + SSL_CTX_clear_extra_chain_certs(ctx); for (int i = 0; i < sk_X509_num(extra_certs); i++) { X509* ca = sk_X509_value(extra_certs, i);