serverBump->attachServerSSL(serverSession.get());
// store peeked cert to check SQUID_X509_V_ERR_CERT_CHANGE
if (X509 *peeked_cert = serverBump->serverCert.get()) {
- CRYPTO_add(&(peeked_cert->references),1,CRYPTO_LOCK_X509);
+ X509_up_ref(peeked_cert);
SSL_set_ex_data(serverSession.get(), ssl_ex_index_ssl_peeked_cert, peeked_cert);
}
}
X509 *signingCert = port.signingCert.get();
if (SSL_CTX_add_extra_chain_cert(ctx.get(), signingCert)) {
// increase the certificate lock
- CRYPTO_add(&(signingCert->references),1,CRYPTO_LOCK_X509);
+ X509_up_ref(signingCert);
} else {
const int ssl_error = ERR_get_error();
debugs(33, DBG_IMPORTANT, "WARNING: can not add signing certificate to SSL context chain: " << ERR_error_string(ssl_error, NULL));
X509 *cert = sk_X509_value(chain, i);
if (SSL_CTX_add_extra_chain_cert(ctx.get(), cert)) {
// increase the certificate lock
- CRYPTO_add(&(cert->references),1,CRYPTO_LOCK_X509);
+ X509_up_ref(cert);
} else {
const int ssl_error = ERR_get_error();
debugs(83, DBG_IMPORTANT, "WARNING: can not add certificate to SSL context chain: " << ERR_error_string(ssl_error, NULL));
/// initialize a TLS client context with OpenSSL specific settings
bool InitClientContext(Security::ContextPointer &, Security::PeerOptions &, long options, long flags);
+#if defined(CRYPTO_LOCK_X509)
+// portability wrapper for OpenSSL 1.0 vs 1.1
+// use Security::CertPointer instead where possible
+inline int X509_up_ref(X509 *t) {if (t) CRYPTO_add(&t->references, 1, CRYPTO_LOCK_X509); return 0;}
+#endif
+
} //namespace Ssl
/// \ingroup ServerProtocolSSLAPI