forked from wolfSSL/wolfssl
add KEEP_PEER_CERT flag for non opensslextra peer cert storage, ssn3
This commit is contained in:
@ -471,6 +471,13 @@
|
|||||||
#define USE_CYASSL_MEMORY
|
#define USE_CYASSL_MEMORY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
|
||||||
|
#undef KEEP_PEER_CERT
|
||||||
|
#define KEEP_PEER_CERT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Place any other flags or defines here */
|
/* Place any other flags or defines here */
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@
|
|||||||
#define SHA256_DIGEST_SIZE 32
|
#define SHA256_DIGEST_SIZE 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -1634,7 +1635,7 @@ struct CYASSL {
|
|||||||
byte hsInfoOn; /* track handshake info */
|
byte hsInfoOn; /* track handshake info */
|
||||||
byte toInfoOn; /* track timeout info */
|
byte toInfoOn; /* track timeout info */
|
||||||
#endif
|
#endif
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef KEEP_PEER_CERT
|
||||||
CYASSL_X509 peerCert; /* X509 peer cert */
|
CYASSL_X509 peerCert; /* X509 peer cert */
|
||||||
#endif
|
#endif
|
||||||
#ifdef FORTRESS
|
#ifdef FORTRESS
|
||||||
@ -1868,8 +1869,6 @@ CYASSL_LOCAL int GrowInputBuffer(CYASSL* ssl, int size, int usedLength);
|
|||||||
|
|
||||||
#endif /* NO_TLS */
|
#endif /* NO_TLS */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef double timer_d;
|
typedef double timer_d;
|
||||||
|
|
||||||
CYASSL_LOCAL timer_d Timer(void);
|
CYASSL_LOCAL timer_d Timer(void);
|
||||||
|
@ -253,11 +253,12 @@ static INLINE int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
|
|||||||
|
|
||||||
static INLINE void showPeer(CYASSL* ssl)
|
static INLINE void showPeer(CYASSL* ssl)
|
||||||
{
|
{
|
||||||
#ifdef OPENSSL_EXTRA
|
|
||||||
|
|
||||||
CYASSL_CIPHER* cipher;
|
CYASSL_CIPHER* cipher;
|
||||||
|
#ifdef KEEP_PEER_CERT
|
||||||
CYASSL_X509* peer = CyaSSL_get_peer_certificate(ssl);
|
CYASSL_X509* peer = CyaSSL_get_peer_certificate(ssl);
|
||||||
if (peer) {
|
if (peer) {
|
||||||
|
#ifdef OPENSSL_EXTRA
|
||||||
char* altName;
|
char* altName;
|
||||||
char* issuer = CyaSSL_X509_NAME_oneline(
|
char* issuer = CyaSSL_X509_NAME_oneline(
|
||||||
CyaSSL_X509_get_issuer_name(peer), 0, 0);
|
CyaSSL_X509_get_issuer_name(peer), 0, 0);
|
||||||
@ -289,14 +290,17 @@ static INLINE void showPeer(CYASSL* ssl)
|
|||||||
|
|
||||||
XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
|
XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
|
||||||
XFREE(issuer, 0, DYNAMIC_TYPE_OPENSSL);
|
XFREE(issuer, 0, DYNAMIC_TYPE_OPENSSL);
|
||||||
|
#else
|
||||||
|
printf("peer has a cert!\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("peer has no cert!\n");
|
printf("peer has no cert!\n");
|
||||||
|
#endif
|
||||||
printf("SSL version is %s\n", CyaSSL_get_version(ssl));
|
printf("SSL version is %s\n", CyaSSL_get_version(ssl));
|
||||||
|
|
||||||
cipher = CyaSSL_get_current_cipher(ssl);
|
cipher = CyaSSL_get_current_cipher(ssl);
|
||||||
printf("SSL cipher suite is %s\n", CyaSSL_CIPHER_get_name(cipher));
|
printf("SSL cipher suite is %s\n", CyaSSL_CIPHER_get_name(cipher));
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SESSION_CERTS) && defined(SHOW_CERTS)
|
#if defined(SESSION_CERTS) && defined(SHOW_CERTS)
|
||||||
{
|
{
|
||||||
|
@ -1203,7 +1203,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx)
|
|||||||
ssl->buffers.prevSent = 0;
|
ssl->buffers.prevSent = 0;
|
||||||
ssl->buffers.plainSz = 0;
|
ssl->buffers.plainSz = 0;
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef KEEP_PEER_CERT
|
||||||
ssl->peerCert.derCert.buffer = NULL;
|
ssl->peerCert.derCert.buffer = NULL;
|
||||||
ssl->peerCert.altNames = NULL;
|
ssl->peerCert.altNames = NULL;
|
||||||
ssl->peerCert.altNamesNext = NULL;
|
ssl->peerCert.altNamesNext = NULL;
|
||||||
@ -1353,7 +1353,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx)
|
|||||||
ssl->buffers.dtlsCtx.peer.sz = 0;
|
ssl->buffers.dtlsCtx.peer.sz = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef KEEP_PEER_CERT
|
||||||
ssl->peerCert.issuer.sz = 0;
|
ssl->peerCert.issuer.sz = 0;
|
||||||
ssl->peerCert.subject.sz = 0;
|
ssl->peerCert.subject.sz = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -1565,10 +1565,12 @@ void SSL_ResourceFree(CYASSL* ssl)
|
|||||||
XFREE(ssl->buffers.dtlsCtx.peer.sa, ssl->heap, DYNAMIC_TYPE_SOCKADDR);
|
XFREE(ssl->buffers.dtlsCtx.peer.sa, ssl->heap, DYNAMIC_TYPE_SOCKADDR);
|
||||||
ssl->buffers.dtlsCtx.peer.sa = NULL;
|
ssl->buffers.dtlsCtx.peer.sa = NULL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
|
#if defined(KEEP_PEER_CERT) || defined(GOAHEAD_WS)
|
||||||
XFREE(ssl->peerCert.derCert.buffer, ssl->heap, DYNAMIC_TYPE_CERT);
|
XFREE(ssl->peerCert.derCert.buffer, ssl->heap, DYNAMIC_TYPE_CERT);
|
||||||
if (ssl->peerCert.altNames)
|
if (ssl->peerCert.altNames)
|
||||||
FreeAltNames(ssl->peerCert.altNames, ssl->heap);
|
FreeAltNames(ssl->peerCert.altNames, ssl->heap);
|
||||||
|
#endif
|
||||||
|
#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
|
||||||
CyaSSL_BIO_free(ssl->biord);
|
CyaSSL_BIO_free(ssl->biord);
|
||||||
if (ssl->biord != ssl->biowr) /* in case same as write */
|
if (ssl->biord != ssl->biowr) /* in case same as write */
|
||||||
CyaSSL_BIO_free(ssl->biowr);
|
CyaSSL_BIO_free(ssl->biowr);
|
||||||
@ -2831,7 +2833,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx)
|
|||||||
|
|
||||||
#endif /* HAVE_CRL */
|
#endif /* HAVE_CRL */
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef KEEP_PEER_CERT
|
||||||
/* set X509 format for peer cert even if fatal */
|
/* set X509 format for peer cert even if fatal */
|
||||||
XSTRNCPY(ssl->peerCert.issuer.name, dCert.issuer, ASN_NAME_MAX);
|
XSTRNCPY(ssl->peerCert.issuer.name, dCert.issuer, ASN_NAME_MAX);
|
||||||
ssl->peerCert.issuer.name[ASN_NAME_MAX - 1] = '\0';
|
ssl->peerCert.issuer.name[ASN_NAME_MAX - 1] = '\0';
|
||||||
@ -2955,7 +2957,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx)
|
|||||||
store.error = ret;
|
store.error = ret;
|
||||||
store.error_depth = totalCerts;
|
store.error_depth = totalCerts;
|
||||||
store.domain = domain;
|
store.domain = domain;
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef KEEP_PEER_CERT
|
||||||
store.current_cert = &ssl->peerCert;
|
store.current_cert = &ssl->peerCert;
|
||||||
#else
|
#else
|
||||||
store.current_cert = NULL;
|
store.current_cert = NULL;
|
||||||
|
12
src/ssl.c
12
src/ssl.c
@ -3960,8 +3960,8 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
|||||||
ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
|
ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
|
||||||
ssl->options.side);
|
ssl->options.side);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* return true if connection established */
|
/* return true if connection established */
|
||||||
int CyaSSL_is_init_finished(CYASSL* ssl)
|
int CyaSSL_is_init_finished(CYASSL* ssl)
|
||||||
{
|
{
|
||||||
@ -3974,7 +3974,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
|
||||||
void CyaSSL_CTX_set_tmp_rsa_callback(CYASSL_CTX* ctx,
|
void CyaSSL_CTX_set_tmp_rsa_callback(CYASSL_CTX* ctx,
|
||||||
CYASSL_RSA*(*f)(CYASSL*, int, int))
|
CYASSL_RSA*(*f)(CYASSL*, int, int))
|
||||||
{
|
{
|
||||||
@ -5452,8 +5452,8 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
|||||||
(void)flags;
|
(void)flags;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef KEEP_PEER_CERT
|
||||||
CYASSL_X509* CyaSSL_get_peer_certificate(CYASSL* ssl)
|
CYASSL_X509* CyaSSL_get_peer_certificate(CYASSL* ssl)
|
||||||
{
|
{
|
||||||
CYASSL_ENTER("SSL_get_peer_certificate");
|
CYASSL_ENTER("SSL_get_peer_certificate");
|
||||||
@ -5462,9 +5462,9 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPENSSL_EXTRA
|
||||||
|
|
||||||
int CyaSSL_set_ex_data(CYASSL* ssl, int idx, void* data)
|
int CyaSSL_set_ex_data(CYASSL* ssl, int idx, void* data)
|
||||||
{
|
{
|
||||||
#ifdef FORTRESS
|
#ifdef FORTRESS
|
||||||
|
Reference in New Issue
Block a user