File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14921,6 +14921,23 @@ WOLFSSL_X509* wolfSSL_get_certificate(WOLFSSL* ssl)
1492114921
1492214922 if (ssl->buffers.weOwnCert) {
1492314923 if (ssl->ourCert == NULL) {
14924+ /* Check if ctx has ourCert set - if so, use it instead of creating
14925+ * a new X509. This maintains pointer compatibility with
14926+ * applications (like nginx OCSP stapling) that use the X509 pointer
14927+ * from SSL_CTX_use_certificate as a lookup key. */
14928+ if (ssl->ctx != NULL && ssl->ctx->ourCert != NULL) {
14929+ /* Compare cert buffers to make sure they are the same */
14930+ if (ssl->buffers.certificate == NULL ||
14931+ ssl->buffers.certificate->buffer == NULL ||
14932+ (ssl->buffers.certificate->length ==
14933+ ssl->ctx->certificate->length &&
14934+ XMEMCMP(ssl->buffers.certificate->buffer,
14935+ ssl->ctx->certificate->buffer,
14936+ ssl->buffers.certificate->length) == 0)) {
14937+ ssl->ourCert = ssl->ctx->ourCert;
14938+ return ssl->ctx->ourCert;
14939+ }
14940+ }
1492414941 if (ssl->buffers.certificate == NULL) {
1492514942 WOLFSSL_MSG("Certificate buffer not set!");
1492614943 return NULL;
You can’t perform that action at this time.
0 commit comments