Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion example/plugins/c-api/verify_cert/verify_cert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ CB_clientcert(TSCont /* contp */, TSEvent /* event */, void *edata)
TSVConn ssl_vc = reinterpret_cast<TSVConn>(edata);
TSSslConnection sslobj = TSVConnSslConnectionGet(ssl_vc);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
TSDebug(PLUGIN_NAME, "plugin verify_cert verifying client certificate");
if (cert) {
debug_certificate("client certificate subject CN is %s", X509_get_subject_name(cert));
Expand Down
4 changes: 4 additions & 0 deletions iocore/net/P_SSLNetVConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ class SSLNetVConnection : public UnixNetVConnection,
bool
peer_provided_cert() const override
{
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(this->ssl);
#else
X509 *cert = SSL_get_peer_certificate(this->ssl);
#endif
if (cert != nullptr) {
X509_free(cert);
return true;
Expand Down
8 changes: 8 additions & 0 deletions iocore/net/SSLNetVConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,11 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err)
switch (ssl_error) {
case SSL_ERROR_NONE:
if (is_debug_tag_set("ssl")) {
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif

Debug("ssl", "SSL server handshake completed successfully");
if (cert) {
Expand Down Expand Up @@ -1535,7 +1539,11 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err)
switch (ssl_error) {
case SSL_ERROR_NONE:
if (is_debug_tag_set("ssl")) {
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif

Debug("ssl", "SSL client handshake completed successfully");

Expand Down
4 changes: 4 additions & 0 deletions plugins/experimental/sslheaders/sslheaders.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ template <bool IsClient> class WrapX509
void
_set()
{
#ifdef OPENSSL_IS_OPENSSL3
_x509 = (IsClient ? SSL_get1_peer_certificate : SSL_get_certificate)(_ssl);
#else
_x509 = (IsClient ? SSL_get_peer_certificate : SSL_get_certificate)(_ssl);
#endif
}
};
} // end anonymous namespace
Expand Down
42 changes: 35 additions & 7 deletions plugins/experimental/wasm/ats_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,11 @@ Context::getProperty(std::string_view path, std::string *result)
TSVConn client_conn = TSHttpSsnClientVConnGet(ssnp);
TSSslConnection sslobj = TSVConnSslConnectionGet(client_conn);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
if (cert != nullptr) {
m = true;
X509_free(cert);
Expand Down Expand Up @@ -631,7 +635,11 @@ Context::getProperty(std::string_view path, std::string *result)
TSVConn client_conn = TSHttpSsnClientVConnGet(ssnp);
TSSslConnection sslobj = TSVConnSslConnectionGet(client_conn);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
if (cert != nullptr) {
print_certificate(result, X509_get_subject_name(cert));
X509_free(cert);
Expand Down Expand Up @@ -665,7 +673,11 @@ Context::getProperty(std::string_view path, std::string *result)
TSVConn client_conn = TSHttpSsnClientVConnGet(ssnp);
TSSslConnection sslobj = TSVConnSslConnectionGet(client_conn);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
if (cert != nullptr) {
print_san_certificate(result, cert, GEN_DNS);
X509_free(cert);
Expand Down Expand Up @@ -699,7 +711,11 @@ Context::getProperty(std::string_view path, std::string *result)
TSVConn client_conn = TSHttpSsnClientVConnGet(ssnp);
TSSslConnection sslobj = TSVConnSslConnectionGet(client_conn);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
if (cert != nullptr) {
print_san_certificate(result, cert, GEN_URI);
X509_free(cert);
Expand Down Expand Up @@ -784,7 +800,11 @@ Context::getProperty(std::string_view path, std::string *result)
TSVConn client_conn = TSHttpSsnServerVConnGet(ssnp);
TSSslConnection sslobj = TSVConnSslConnectionGet(client_conn);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
if (cert != nullptr) {
print_certificate(result, X509_get_subject_name(cert));
X509_free(cert);
Expand Down Expand Up @@ -818,7 +838,11 @@ Context::getProperty(std::string_view path, std::string *result)
TSVConn client_conn = TSHttpSsnServerVConnGet(ssnp);
TSSslConnection sslobj = TSVConnSslConnectionGet(client_conn);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
if (cert != nullptr) {
print_san_certificate(result, cert, GEN_DNS);
X509_free(cert);
Expand Down Expand Up @@ -852,7 +876,11 @@ Context::getProperty(std::string_view path, std::string *result)
TSVConn client_conn = TSHttpSsnServerVConnGet(ssnp);
TSSslConnection sslobj = TSVConnSslConnectionGet(client_conn);
SSL *ssl = reinterpret_cast<SSL *>(sslobj);
X509 *cert = SSL_get_peer_certificate(ssl);
#ifdef OPENSSL_IS_OPENSSL3
X509 *cert = SSL_get1_peer_certificate(ssl);
#else
X509 *cert = SSL_get_peer_certificate(ssl);
#endif
if (cert != nullptr) {
print_san_certificate(result, cert, GEN_URI);
X509_free(cert);
Expand Down