const auto x = ERR_get_error();
fatalf("Failed to allocate TLS client context: %s\n", Security::ErrorString(x));
}
- ctx = Security::ContextPointer(t, [](SSL_CTX *p) {
- SSL_CTX_free(p);
- });
+ ctx = convertContextFromRawPtr(t);
#elif USE_GNUTLS
// Initialize for X.509 certificate exchange
if (const int x = gnutls_certificate_allocate_credentials(&t)) {
fatalf("Failed to allocate TLS client context: %s\n", Security::ErrorString(x));
}
- ctx = Security::ContextPointer(t, [](gnutls_certificate_credentials_t p) {
- gnutls_certificate_free_credentials(p);
- });
+ ctx = convertContextFromRawPtr(t);
#else
debugs(83, 1, "WARNING: Failed to allocate TLS client context: No TLS library");
fatalf("Unknown TLS option '%s'", err);
}
parsedOptions = Security::ParsedOptions(op, [](gnutls_priority_t p) {
+ debugs(83, 5, "gnutls_priority_deinit p=" << (void*)p);
gnutls_priority_deinit(p);
});
#endif
Security::CertRevokeList parsedCrl; ///< CRL to use when verifying the remote end certificate
protected:
+ template<typename T>
+ Security::ContextPointer convertContextFromRawPtr(T ctx) const {
+#if USE_OPENSSL
+ return ContextPointer(ctx, [](SSL_CTX *p) {
+ debugs(83, 5, "SSL_free ctx=" << (void*)p);
+ SSL_CTX_free(p);
+ });
+#elif USE_GNUTLS
+ return Security::ContextPointer(ctx, [](gnutls_certificate_credentials_t p) {
+ debugs(83, 5, "gnutls_certificate_free_credentials ctx=" << (void*)p);
+ gnutls_certificate_free_credentials(p);
+ });
+#else
+ assert(!ctx);
+ return Security::ContextPointer();
+#endif
+ }
+
int sslVersion = 0;
/// flags governing Squid internal TLS operations
const auto x = ERR_get_error();
debugs(83, DBG_CRITICAL, "ERROR: Failed to allocate TLS server context: " << Security::ErrorString(x));
}
- ctx = Security::ContextPointer(t, [](SSL_CTX *p) {
- SSL_CTX_free(p);
- });
+ ctx = convertContextFromRawPtr(t);
#elif USE_GNUTLS
// Initialize for X.509 certificate exchange
if (const int x = gnutls_certificate_allocate_credentials(&t)) {
debugs(83, DBG_CRITICAL, "ERROR: Failed to allocate TLS server context: " << Security::ErrorString(x));
}
- ctx = Security::ContextPointer(t, [](gnutls_certificate_credentials_t p) {
- gnutls_certificate_free_credentials(p);
- });
+ ctx = convertContextFromRawPtr(t);
#else
debugs(83, DBG_CRITICAL, "ERROR: Failed to allocate TLS server context: No TLS library");