MCPcopy Create free account
hub / github.com/F-Stack/f-stack / connTLSGetPeerCert

Function connTLSGetPeerCert

app/redis-6.2.6/src/tls.c:963–982  ·  view source on GitHub ↗

Fetch the peer certificate used for authentication on the specified * connection and return it as a PEM-encoded sds. */

Source from the content-addressed store, hash-verified

961 * connection and return it as a PEM-encoded sds.
962 */
963sds connTLSGetPeerCert(connection *conn_) {
964 tls_connection *conn = (tls_connection *) conn_;
965 if (conn_->type->get_type(conn_) != CONN_TYPE_TLS || !conn->ssl) return NULL;
966
967 X509 *cert = SSL_get_peer_certificate(conn->ssl);
968 if (!cert) return NULL;
969
970 BIO *bio = BIO_new(BIO_s_mem());
971 if (bio == NULL || !PEM_write_bio_X509(bio, cert)) {
972 if (bio != NULL) BIO_free(bio);
973 return NULL;
974 }
975
976 const char *bio_ptr;
977 long long bio_len = BIO_get_mem_data(bio, &bio_ptr);
978 sds cert_pem = sdsnewlen(bio_ptr, bio_len);
979 BIO_free(bio);
980
981 return cert_pem;
982}
983
984#else /* USE_OPENSSL */
985

Callers 1

RM_GetClientCertificateFunction · 0.85

Calls 1

sdsnewlenFunction · 0.85

Tested by

no test coverage detected