mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 14:00:48 +02:00
Merge pull request #10037 from JacobBarthelmeh/nightly
fix examples to follow options.h config
This commit is contained in:
@@ -32,9 +32,6 @@
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#undef TEST_OPENSSL_COEXIST /* can't use this option with this example */
|
||||
#undef OPENSSL_COEXIST /* can't use this option with this example */
|
||||
|
||||
#include <wolfssl/ssl.h>
|
||||
|
||||
#ifdef WOLFSSL_WOLFSENTRY_HOOKS
|
||||
@@ -1743,7 +1740,7 @@ static const char* client_usage_msg[][80] = {
|
||||
static void showPeerPEM(WOLFSSL* ssl)
|
||||
{
|
||||
#if defined(OPENSSL_EXTRA) && defined(KEEP_PEER_CERT) && !defined(NO_BIO) && \
|
||||
defined(WOLFSSL_CERT_GEN)
|
||||
defined(WOLFSSL_CERT_GEN) && !defined(OPENSSL_COEXIST)
|
||||
WOLFSSL_X509* peer = wolfSSL_get_peer_certificate(ssl);
|
||||
if (peer) {
|
||||
WOLFSSL_BIO* bioOut = wolfSSL_BIO_new(wolfSSL_BIO_s_file());
|
||||
@@ -1751,7 +1748,7 @@ static void showPeerPEM(WOLFSSL* ssl)
|
||||
LOG_ERROR("failed to get bio on stdout\n");
|
||||
}
|
||||
else {
|
||||
if (wolfSSL_BIO_set_fp(bioOut, stdout, BIO_NOCLOSE)
|
||||
if (wolfSSL_BIO_set_fp(bioOut, stdout, WOLFSSL_BIO_NOCLOSE)
|
||||
!= WOLFSSL_SUCCESS) {
|
||||
LOG_ERROR("failed to set stdout to bio output\n");
|
||||
wolfSSL_BIO_free(bioOut);
|
||||
@@ -3623,7 +3620,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
) {
|
||||
#ifdef NO_FILESYSTEM
|
||||
if (wolfSSL_CTX_use_PrivateKey_buffer(ctx, client_key_der_2048,
|
||||
sizeof_client_key_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
sizeof_client_key_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
err_sys("can't load client private key buffer");
|
||||
#elif !defined(TEST_LOAD_BUFFER)
|
||||
if (wolfSSL_CTX_use_PrivateKey_file(ctx, ourKey, fileFormat)
|
||||
@@ -3663,7 +3660,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
#endif
|
||||
#ifdef NO_FILESYSTEM
|
||||
if (wolfSSL_CTX_load_verify_buffer(ctx, ca_cert_der_2048,
|
||||
sizeof_ca_cert_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
|
||||
sizeof_ca_cert_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
err_sys("can't load ca buffer, Please run from wolfSSL home dir");
|
||||
}
|
||||
@@ -3687,7 +3684,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
#ifdef NO_FILESYSTEM
|
||||
if (doPeerCheck != 0 &&
|
||||
wolfSSL_CTX_load_verify_buffer(ctx, ca_ecc_cert_der_256,
|
||||
sizeof_ca_ecc_cert_der_256, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
|
||||
sizeof_ca_ecc_cert_der_256, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
err_sys("can't load ecc ca buffer");
|
||||
}
|
||||
@@ -3965,7 +3962,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
if (useClientCert && loadCertKeyIntoSSLObj){
|
||||
#ifdef NO_FILESYSTEM
|
||||
if (wolfSSL_use_certificate_buffer(ssl, client_cert_der_2048,
|
||||
sizeof_client_cert_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
|
||||
sizeof_client_cert_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
err_sys("can't load client cert buffer");
|
||||
}
|
||||
@@ -3988,7 +3985,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
) {
|
||||
#ifdef NO_FILESYSTEM
|
||||
if (wolfSSL_CTX_use_PrivateKey_buffer(ctx, client_key_der_2048,
|
||||
sizeof_client_key_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
sizeof_client_key_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
err_sys("can't load client private key buffer");
|
||||
#elif !defined(TEST_LOAD_BUFFER)
|
||||
if (wolfSSL_use_PrivateKey_file(ssl, ourKey, fileFormat)
|
||||
@@ -4381,7 +4378,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
#ifndef NO_BIO
|
||||
/* print out session to stdout */
|
||||
{
|
||||
WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, WOLFSSL_BIO_NOCLOSE);
|
||||
if (bio != NULL) {
|
||||
if (wolfSSL_SESSION_print(bio, wolfSSL_get_session(ssl)) !=
|
||||
WOLFSSL_SUCCESS) {
|
||||
|
||||
+58
-68
@@ -32,16 +32,6 @@
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#undef TEST_OPENSSL_COEXIST /* can't use this option with this example */
|
||||
#undef OPENSSL_COEXIST /* can't use this option with this example */
|
||||
|
||||
/* Force enable the compatibility macros for this example */
|
||||
#ifndef OPENSSL_EXTRA_X509_SMALL
|
||||
#define OPENSSL_EXTRA_X509_SMALL
|
||||
#endif
|
||||
#include <wolfssl/openssl/ssl.h>
|
||||
|
||||
#undef OPENSSL_EXTRA_X509_SMALL
|
||||
#include <wolfssl/ssl.h> /* name change portability layer */
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
@@ -342,15 +332,15 @@ static int TestEmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
|
||||
}
|
||||
#endif /* WOLFSSL_DTLS && USE_WOLFSSL_IO */
|
||||
|
||||
static int NonBlockingSSL_Accept(SSL* ssl)
|
||||
static int NonBlockingSSL_Accept(WOLFSSL* ssl)
|
||||
{
|
||||
#ifndef WOLFSSL_CALLBACKS
|
||||
int ret = SSL_accept(ssl);
|
||||
int ret = wolfSSL_accept(ssl);
|
||||
#else
|
||||
int ret = wolfSSL_accept_ex(ssl, srvHandShakeCB, srvTimeoutCB, srvTo);
|
||||
#endif
|
||||
int error = SSL_get_error(ssl, 0);
|
||||
SOCKET_T sockfd = (SOCKET_T)SSL_get_fd(ssl);
|
||||
int error = wolfSSL_get_error(ssl, ret);
|
||||
SOCKET_T sockfd = (SOCKET_T)wolfSSL_get_fd(ssl);
|
||||
int select_ret = 0;
|
||||
|
||||
while (ret != WOLFSSL_SUCCESS &&
|
||||
@@ -396,12 +386,12 @@ static int NonBlockingSSL_Accept(SSL* ssl)
|
||||
#endif
|
||||
) {
|
||||
#ifndef WOLFSSL_CALLBACKS
|
||||
ret = SSL_accept(ssl);
|
||||
ret = wolfSSL_accept(ssl);
|
||||
#else
|
||||
ret = wolfSSL_accept_ex(ssl,
|
||||
srvHandShakeCB, srvTimeoutCB, srvTo);
|
||||
#endif
|
||||
error = SSL_get_error(ssl, 0);
|
||||
error = wolfSSL_get_error(ssl, ret);
|
||||
}
|
||||
else if (select_ret == TEST_TIMEOUT && !wolfSSL_dtls(ssl)) {
|
||||
error = WOLFSSL_ERROR_WANT_READ;
|
||||
@@ -425,7 +415,7 @@ static int NonBlockingSSL_Accept(SSL* ssl)
|
||||
}
|
||||
|
||||
/* Echo number of bytes specified by -B arg */
|
||||
int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
|
||||
int ServerEchoData(WOLFSSL* ssl, int clientfd, int echoData, int block,
|
||||
size_t throughput)
|
||||
{
|
||||
int ret = 0, err;
|
||||
@@ -457,9 +447,9 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
|
||||
|
||||
/* Read data */
|
||||
while (rx_pos < len) {
|
||||
ret = SSL_read(ssl, &buffer[rx_pos], len - rx_pos);
|
||||
ret = wolfSSL_read(ssl, &buffer[rx_pos], len - rx_pos);
|
||||
if (ret <= 0) {
|
||||
err = SSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
|
||||
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
||||
@@ -494,7 +484,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
|
||||
|
||||
/* Write data */
|
||||
WOLFSSL_ASYNC_WHILE_PENDING(
|
||||
ret = SSL_write(ssl, buffer, (int)min((word32)len, (word32)rx_pos)),
|
||||
ret = wolfSSL_write(ssl, buffer, (int)min((word32)len, (word32)rx_pos)),
|
||||
ret <= 0);
|
||||
if (ret != (int)min((word32)len, (word32)rx_pos)) {
|
||||
LOG_ERROR("SSL_write echo error %d\n", err);
|
||||
@@ -545,16 +535,16 @@ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
|
||||
/* Read data */
|
||||
do {
|
||||
err = 0; /* reset error */
|
||||
ret = SSL_read(ssl, input, inputLen);
|
||||
ret = wolfSSL_read(ssl, input, inputLen);
|
||||
if (ret < 0) {
|
||||
err = SSL_get_error(ssl, ret);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
|
||||
#ifdef HAVE_SECURE_RENEGOTIATION
|
||||
if (err == WC_NO_ERR_TRACE(APP_DATA_READY)) {
|
||||
/* If we receive a message during renegotiation
|
||||
* then just print it. We return the message sent
|
||||
* after the renegotiation. */
|
||||
ret = SSL_read(ssl, input, inputLen);
|
||||
ret = wolfSSL_read(ssl, input, inputLen);
|
||||
if (ret >= 0) {
|
||||
/* null terminate message */
|
||||
input[ret] = '\0';
|
||||
@@ -563,7 +553,7 @@ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
|
||||
err = WOLFSSL_ERROR_WANT_READ;
|
||||
}
|
||||
else {
|
||||
err = SSL_get_error(ssl, ret);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -588,12 +578,12 @@ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
|
||||
#endif
|
||||
) {
|
||||
LOG_ERROR("SSL_read input error %d, %s\n", err,
|
||||
ERR_error_string((unsigned long)err, buffer));
|
||||
wolfSSL_ERR_error_string((unsigned long)err, buffer));
|
||||
err_sys_ex(runWithErrors, "SSL_read failed");
|
||||
}
|
||||
}
|
||||
else if (SSL_get_error(ssl, 0) == 0 &&
|
||||
tcp_select(SSL_get_fd(ssl), 0) == TEST_RECV_READY) {
|
||||
else if (wolfSSL_get_error(ssl, 0) == 0 &&
|
||||
tcp_select(wolfSSL_get_fd(ssl), 0) == TEST_RECV_READY) {
|
||||
/* do a peek and check for "pending" */
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
err = 0;
|
||||
@@ -606,7 +596,7 @@ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
|
||||
}
|
||||
#endif
|
||||
ret = wolfSSL_peek(ssl, buffer, 0);
|
||||
err = SSL_get_error(ssl, ret);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
} while (err == WC_NO_ERR_TRACE(WC_PENDING_E)
|
||||
|| err == WOLFSSL_ERROR_WANT_READ
|
||||
|| err == WOLFSSL_ERROR_WANT_WRITE);
|
||||
@@ -641,9 +631,9 @@ static void ServerWrite(WOLFSSL* ssl, const char* output, int outputLen)
|
||||
|
||||
do {
|
||||
err = 0; /* reset error */
|
||||
ret = SSL_write(ssl, output, len);
|
||||
ret = wolfSSL_write(ssl, output, len);
|
||||
if (ret <= 0) {
|
||||
err = SSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
|
||||
@@ -662,7 +652,7 @@ static void ServerWrite(WOLFSSL* ssl, const char* output, int outputLen)
|
||||
if (ret != outputLen) {
|
||||
char buffer[WOLFSSL_MAX_ERROR_SZ];
|
||||
LOG_ERROR("SSL_write msg error %d, %s\n", err,
|
||||
ERR_error_string((unsigned long)err, buffer));
|
||||
wolfSSL_ERR_error_string((unsigned long)err, buffer));
|
||||
err_sys_ex(runWithErrors, "SSL_write failed");
|
||||
}
|
||||
}
|
||||
@@ -1614,8 +1604,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
socklen_t client_len;
|
||||
|
||||
wolfSSL_method_func method = NULL;
|
||||
SSL_CTX* ctx = 0;
|
||||
SSL* ssl = 0;
|
||||
WOLFSSL_CTX* ctx = 0;
|
||||
WOLFSSL* ssl = 0;
|
||||
#ifdef WOLFSSL_WOLFSENTRY_HOOKS
|
||||
wolfsentry_errcode_t wolfsentry_ret;
|
||||
#endif
|
||||
@@ -2793,7 +2783,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
err_sys_ex(catastrophic, "unable to load static memory and create ctx");
|
||||
#else
|
||||
if (method != NULL) {
|
||||
ctx = SSL_CTX_new(method(NULL));
|
||||
ctx = wolfSSL_CTX_new(method(NULL));
|
||||
}
|
||||
#ifdef WOLFSSL_CALLBACKS
|
||||
wolfSSL_CTX_set_msg_callback(ctx, msgDebugCb);
|
||||
@@ -2905,7 +2895,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
#endif /* WOLFSSL_SNIFFER && WOLFSSL_STATIC_EPHEMERAL && WOLFSSL_PEM_TO_DER */
|
||||
|
||||
if (cipherList && !useDefCipherList) {
|
||||
if (SSL_CTX_set_cipher_list(ctx, cipherList) != WOLFSSL_SUCCESS)
|
||||
if (wolfSSL_CTX_set_cipher_list(ctx, cipherList) != WOLFSSL_SUCCESS)
|
||||
err_sys_ex(runWithErrors, "server can't set custom cipher list");
|
||||
}
|
||||
|
||||
@@ -2936,7 +2926,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ENCRYPTED_KEYS
|
||||
SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
|
||||
wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
|
||||
#endif
|
||||
|
||||
#if !defined(NO_CERTS)
|
||||
@@ -2948,7 +2938,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
err_sys_ex(catastrophic, "can't load server cert buffer");
|
||||
#elif !defined(TEST_LOAD_BUFFER)
|
||||
#if defined(WOLFSSL_PEM_TO_DER)
|
||||
if (SSL_CTX_use_certificate_chain_file(ctx, ourCert)
|
||||
if (wolfSSL_CTX_use_certificate_chain_file(ctx, ourCert)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
#else
|
||||
if (wolfSSL_CTX_use_certificate_chain_file_format(ctx, ourCert,
|
||||
@@ -2992,14 +2982,14 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
) {
|
||||
#ifdef NO_FILESYSTEM
|
||||
if (wolfSSL_CTX_use_PrivateKey_buffer(ctx, server_key_der_2048,
|
||||
sizeof_server_key_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
sizeof_server_key_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
err_sys_ex(catastrophic, "can't load server private key buffer");
|
||||
#elif !defined(TEST_LOAD_BUFFER)
|
||||
#if defined(WOLFSSL_PEM_TO_DER)
|
||||
if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, WOLFSSL_FILETYPE_PEM)
|
||||
if (wolfSSL_CTX_use_PrivateKey_file(ctx, ourKey, WOLFSSL_FILETYPE_PEM)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
#else
|
||||
if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, WOLFSSL_FILETYPE_ASN1)
|
||||
if (wolfSSL_CTX_use_PrivateKey_file(ctx, ourKey, WOLFSSL_FILETYPE_ASN1)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
#endif
|
||||
err_sys_ex(catastrophic, "can't load server private key file, "
|
||||
@@ -3023,12 +3013,12 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
#ifndef NO_PSK
|
||||
const char *defaultCipherList = cipherList;
|
||||
|
||||
SSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
|
||||
wolfSSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
|
||||
#ifdef WOLFSSL_TLS13
|
||||
wolfSSL_CTX_set_psk_server_tls13_callback(ctx, my_psk_server_tls13_cb);
|
||||
#endif
|
||||
if (sendPskIdentityHint == 1)
|
||||
SSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
|
||||
wolfSSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
|
||||
|
||||
if (defaultCipherList == NULL && !usePskPlus) {
|
||||
#if defined(HAVE_AESGCM) && !defined(NO_DH)
|
||||
@@ -3055,7 +3045,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
#else
|
||||
defaultCipherList = "PSK-AES128-GCM-SHA256";
|
||||
#endif
|
||||
if (SSL_CTX_set_cipher_list(ctx, defaultCipherList)
|
||||
if (wolfSSL_CTX_set_cipher_list(ctx, defaultCipherList)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
err_sys_ex(runWithErrors, "server can't set cipher list 2");
|
||||
}
|
||||
@@ -3085,7 +3075,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
const char* defaultCipherList;
|
||||
defaultCipherList = "ADH-AES256-GCM-SHA384:"
|
||||
"ADH-AES128-SHA";
|
||||
if (SSL_CTX_set_cipher_list(ctx, defaultCipherList)
|
||||
if (wolfSSL_CTX_set_cipher_list(ctx, defaultCipherList)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
err_sys_ex(runWithErrors, "server can't set cipher list 4");
|
||||
}
|
||||
@@ -3097,7 +3087,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
if using PSK Plus then verify peer certs except PSK suites */
|
||||
if (doCliCertCheck && (usePsk == 0 || usePskPlus) && useAnon == 0) {
|
||||
unsigned int verify_flags = 0;
|
||||
SSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER |
|
||||
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER |
|
||||
(usePskPlus ? WOLFSSL_VERIFY_FAIL_EXCEPT_PSK :
|
||||
WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT),
|
||||
(myVerifyAction == VERIFY_OVERRIDE_DATE_ERR ||
|
||||
@@ -3154,7 +3144,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
if (cipherList == NULL && version < 4) {
|
||||
/* static RSA or static ECC cipher suites */
|
||||
const char* staticCipherList = "AES128-SHA:ECDH-ECDSA-AES128-SHA";
|
||||
if (SSL_CTX_set_cipher_list(ctx, staticCipherList) != WOLFSSL_SUCCESS) {
|
||||
if (wolfSSL_CTX_set_cipher_list(ctx, staticCipherList) != WOLFSSL_SUCCESS) {
|
||||
err_sys_ex(runWithErrors, "server can't set cipher list 3");
|
||||
}
|
||||
}
|
||||
@@ -3304,7 +3294,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
SetupPkCallbacks(ctx);
|
||||
#endif
|
||||
|
||||
ssl = SSL_new(ctx);
|
||||
ssl = wolfSSL_new(ctx);
|
||||
if (ssl == NULL)
|
||||
err_sys_ex(catastrophic, "unable to create an SSL object");
|
||||
|
||||
@@ -3321,7 +3311,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
err_sys_ex(catastrophic, "can't load server cert buffer");
|
||||
#elif !defined(TEST_LOAD_BUFFER)
|
||||
if (SSL_use_certificate_chain_file(ssl, ourCert)
|
||||
if (wolfSSL_use_certificate_chain_file(ssl, ourCert)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
err_sys_ex(catastrophic, "can't load server cert file, check file "
|
||||
"and run from wolfSSL home dir");
|
||||
@@ -3339,10 +3329,10 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
) {
|
||||
#if defined(NO_FILESYSTEM)
|
||||
if (wolfSSL_use_PrivateKey_buffer(ssl, server_key_der_2048,
|
||||
sizeof_server_key_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
sizeof_server_key_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
|
||||
err_sys_ex(catastrophic, "can't load server private key buffer");
|
||||
#elif !defined(TEST_LOAD_BUFFER)
|
||||
if (SSL_use_PrivateKey_file(ssl, ourKey, WOLFSSL_FILETYPE_PEM)
|
||||
if (wolfSSL_use_PrivateKey_file(ssl, ourKey, WOLFSSL_FILETYPE_PEM)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
err_sys_ex(catastrophic, "can't load server private key file, check"
|
||||
"file and run from wolfSSL home dir");
|
||||
@@ -3458,17 +3448,17 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
err_sys_ex(catastrophic, "can't enable OCSP Stapling "
|
||||
"Certificate Manager");
|
||||
}
|
||||
if (SSL_CTX_load_verify_locations(ctx, ca1, 0) != WOLFSSL_SUCCESS) {
|
||||
if (wolfSSL_CTX_load_verify_locations(ctx, ca1, 0) != WOLFSSL_SUCCESS) {
|
||||
fails++;
|
||||
err_sys_ex(runWithErrors, "can't load ca file, Please run from "
|
||||
"wolfSSL home dir");
|
||||
}
|
||||
if (SSL_CTX_load_verify_locations(ctx, ca2, 0) != WOLFSSL_SUCCESS) {
|
||||
if (wolfSSL_CTX_load_verify_locations(ctx, ca2, 0) != WOLFSSL_SUCCESS) {
|
||||
fails++;
|
||||
err_sys_ex(runWithErrors, "can't load ca file, Please run from "
|
||||
"wolfSSL home dir");
|
||||
}
|
||||
if (SSL_CTX_load_verify_locations(ctx, ca3, 0) != WOLFSSL_SUCCESS) {
|
||||
if (wolfSSL_CTX_load_verify_locations(ctx, ca3, 0) != WOLFSSL_SUCCESS) {
|
||||
fails++;
|
||||
err_sys_ex(runWithErrors, "can't load ca file, Please run from "
|
||||
"wolfSSL home dir");
|
||||
@@ -3542,7 +3532,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
port = readySignal->port;
|
||||
}
|
||||
|
||||
if (SSL_set_fd(ssl, clientfd) != WOLFSSL_SUCCESS) {
|
||||
if (wolfSSL_set_fd(ssl, clientfd) != WOLFSSL_SUCCESS) {
|
||||
err_sys_ex(catastrophic, "error in setting fd");
|
||||
}
|
||||
|
||||
@@ -3707,7 +3697,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
ret = wolfSSL_read_early_data(ssl, input, sizeof(input)-1,
|
||||
&len);
|
||||
if (ret <= 0) {
|
||||
err = SSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
|
||||
/* returns the number of polled items or <0 for
|
||||
@@ -3725,7 +3715,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
} while (err == WC_NO_ERR_TRACE(WC_PENDING_E) || ret > 0);
|
||||
}
|
||||
#endif
|
||||
WOLFSSL_ASYNC_WHILE_PENDING(ret = SSL_accept(ssl),
|
||||
WOLFSSL_ASYNC_WHILE_PENDING(ret = wolfSSL_accept(ssl),
|
||||
ret != WOLFSSL_SUCCESS);
|
||||
}
|
||||
#else
|
||||
@@ -3743,13 +3733,13 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
EarlyDataStatus(ssl);
|
||||
#endif
|
||||
if (ret != WOLFSSL_SUCCESS) {
|
||||
err = SSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
LOG_ERROR("SSL_accept error %d, %s\n", err,
|
||||
ERR_error_string((unsigned long)err, buffer));
|
||||
wolfSSL_ERR_error_string((unsigned long)err, buffer));
|
||||
if (exitWithRet || !runWithErrors) {
|
||||
/* cleanup before exit */
|
||||
SSL_free(ssl); ssl = NULL;
|
||||
SSL_CTX_free(ctx); ctx = NULL;
|
||||
wolfSSL_free(ssl); ssl = NULL;
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
CloseSocket(clientfd);
|
||||
CloseSocket(sockfd);
|
||||
}
|
||||
@@ -3762,7 +3752,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
}
|
||||
|
||||
showPeerEx(ssl, lng_index);
|
||||
if (SSL_state(ssl) != 0) {
|
||||
if (wolfSSL_state(ssl) != 0) {
|
||||
err_sys_ex(runWithErrors, "SSL in error state");
|
||||
}
|
||||
|
||||
@@ -3914,7 +3904,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
|
||||
if (echoData == 0 && throughput == 0) {
|
||||
ServerRead(ssl, input, sizeof(input)-1);
|
||||
err = SSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
}
|
||||
|
||||
#if defined(HAVE_SECURE_RENEGOTIATION) && \
|
||||
@@ -4002,7 +3992,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
#if defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH)
|
||||
if (postHandAuth) {
|
||||
|
||||
SSL_set_verify(ssl, WOLFSSL_VERIFY_PEER |
|
||||
wolfSSL_set_verify(ssl, WOLFSSL_VERIFY_PEER |
|
||||
((usePskPlus) ? WOLFSSL_VERIFY_FAIL_EXCEPT_PSK :
|
||||
WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT), 0);
|
||||
|
||||
@@ -4054,8 +4044,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
err = 0;
|
||||
}
|
||||
if (err != 0) {
|
||||
SSL_free(ssl); ssl = NULL;
|
||||
SSL_CTX_free(ctx); ctx = NULL;
|
||||
wolfSSL_free(ssl); ssl = NULL;
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
CloseSocket(clientfd);
|
||||
CloseSocket(sockfd);
|
||||
((func_args*)args)->return_code = err;
|
||||
@@ -4086,7 +4076,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
}
|
||||
#endif /* WOLFSSL_DTLS13 */
|
||||
|
||||
ret = SSL_shutdown(ssl);
|
||||
ret = wolfSSL_shutdown(ssl);
|
||||
if (wc_shutdown && ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
|
||||
while (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
|
||||
TEST_RECV_READY) {
|
||||
@@ -4115,7 +4105,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
wolfSSL_PrintStatsConn(&ssl_stats);
|
||||
|
||||
#endif
|
||||
SSL_free(ssl); ssl = NULL;
|
||||
wolfSSL_free(ssl); ssl = NULL;
|
||||
|
||||
CloseSocket(clientfd);
|
||||
|
||||
@@ -4144,7 +4134,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
#endif
|
||||
|
||||
CloseSocket(sockfd);
|
||||
SSL_CTX_free(ctx); ctx = NULL;
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
|
||||
((func_args*)args)->return_code = 0;
|
||||
|
||||
|
||||
+12
-11
@@ -31,9 +31,6 @@
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#undef TEST_OPENSSL_COEXIST /* can't use this option with this example */
|
||||
#if defined(OPENSSL_EXTRA) && defined(OPENSSL_COEXIST)
|
||||
#error "Example apps built with OPENSSL_EXTRA can't also be built with OPENSSL_COEXIST."
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||
|
||||
@@ -1236,7 +1233,7 @@ static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr,
|
||||
XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
XFREE(issuer, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
|
||||
#if defined(SHOW_CERTS) && defined(OPENSSL_EXTRA)
|
||||
#if defined(SHOW_CERTS) && defined(OPENSSL_EXTRA) && !defined(OPENSSL_COEXIST)
|
||||
{
|
||||
WOLFSSL_BIO* bio;
|
||||
char buf[WC_ASN_NAME_MAX];
|
||||
@@ -1257,7 +1254,7 @@ static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr,
|
||||
wolfSSL_BIO_free(bio);
|
||||
}
|
||||
}
|
||||
#endif /* SHOW_CERTS && OPENSSL_EXTRA */
|
||||
#endif /* SHOW_CERTS && OPENSSL_EXTRA && !OPENSSL_COEXIST */
|
||||
}
|
||||
/* original ShowX509 to maintain compatibility */
|
||||
static WC_INLINE void ShowX509(WOLFSSL_X509* x509, const char* hdr)
|
||||
@@ -1306,7 +1303,8 @@ static WC_INLINE void showPeerEx(WOLFSSL* ssl, int lng_index)
|
||||
#ifndef NO_DH
|
||||
int bits;
|
||||
#endif
|
||||
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
|
||||
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY) && \
|
||||
!defined(OPENSSL_COEXIST)
|
||||
int nid;
|
||||
#endif
|
||||
#ifdef KEEP_PEER_CERT
|
||||
@@ -1326,7 +1324,8 @@ static WC_INLINE void showPeerEx(WOLFSSL* ssl, int lng_index)
|
||||
|
||||
cipher = wolfSSL_get_current_cipher(ssl);
|
||||
printf("%s %s\n", words[1], wolfSSL_CIPHER_get_name(cipher));
|
||||
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
|
||||
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY) && \
|
||||
!defined(OPENSSL_COEXIST)
|
||||
if (wolfSSL_get_signature_nid(ssl, &nid) == WOLFSSL_SUCCESS) {
|
||||
printf("%s %s\n", words[2], OBJ_nid2sn(nid));
|
||||
}
|
||||
@@ -2509,10 +2508,11 @@ static WC_INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
|
||||
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
|
||||
WOLFSSL_X509* peer;
|
||||
#endif
|
||||
#if defined(OPENSSL_EXTRA) && defined(SHOW_CERTS) && !defined(NO_FILESYSTEM)
|
||||
#if defined(OPENSSL_EXTRA) && defined(SHOW_CERTS) && !defined(NO_FILESYSTEM) \
|
||||
&& !defined(OPENSSL_COEXIST)
|
||||
WOLFSSL_BIO* bio = NULL;
|
||||
WOLFSSL_STACK* sk = NULL;
|
||||
X509* x509 = NULL;
|
||||
WOLFSSL_X509* x509 = NULL;
|
||||
#endif
|
||||
|
||||
/* Verify Callback Arguments:
|
||||
@@ -2560,7 +2560,8 @@ static WC_INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
|
||||
|
||||
XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
XFREE(issuer, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
#if defined(OPENSSL_EXTRA) && defined(SHOW_CERTS) && !defined(NO_FILESYSTEM)
|
||||
#if defined(OPENSSL_EXTRA) && defined(SHOW_CERTS) && !defined(NO_FILESYSTEM) \
|
||||
&& !defined(OPENSSL_COEXIST)
|
||||
/* avoid printing duplicate certs */
|
||||
if (store->depth == 1) {
|
||||
int i;
|
||||
@@ -4879,7 +4880,7 @@ static WC_INLINE word16 GetRandomPort(void)
|
||||
static WC_INLINE void EarlyDataStatus(WOLFSSL* ssl)
|
||||
{
|
||||
int earlyData_status;
|
||||
#ifdef OPENSSL_EXTRA
|
||||
#if defined(OPENSSL_EXTRA) && !defined(OPENSSL_COEXIST)
|
||||
earlyData_status = SSL_get_early_data_status(ssl);
|
||||
#else
|
||||
earlyData_status = wolfSSL_get_early_data_status(ssl);
|
||||
|
||||
Reference in New Issue
Block a user