Topic: [SOLVED] wolfSSL_new return 0
Hi,
I'm trying work with Wolfssl using FreeRTOS+TCP on mpc5748g board.
ret = wolfSSL_Init();
listenfd = socket(AF_INET, SOCK_STREAM, 0);
socket_saddr.sin_family = AF_INET;
socket_saddr.sin_addr.s_addr = PP_HTONL(INADDR_ANY);
socket_saddr.sin_port = lwip_htons(PORT); /* echo server port */
ctx = wolfSSL_CTX_new(wolfSSLv23_server_method());
LWIP_ASSERT("wolfSSL_CTX_new() failed", ctx != NULL);
/* Limit to AES128 - hardware-accelerated */
ret = wolfSSL_CTX_set_cipher_list(ctx, "AES128-SHA");
/* Load CA certificates */
ret = wolfSSL_CTX_load_verify_buffer(ctx, CA_CERT, CA_CERT_SIZE, SSL_FILETYPE_ASN1);
/* Load server certificate */
ret = wolfSSL_CTX_use_certificate_buffer(ctx, SERVER_CERT, SERVER_CERT_SIZE, SSL_FILETYPE_ASN1);
/* Load keys */
ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, SERVER_KEY, SERVER_KEY_SIZE, SSL_FILETYPE_ASN1);
if (bind(listenfd, (struct sockaddr *) &socket_saddr, sizeof(socket_saddr)) == -1) {
LWIP_ASSERT("socket_server_thread(): Socket bind failed.", 0);
}
/* Put socket into listening mode */
if (listen(listenfd, MAX_SERV) == -1) {
LWIP_ASSERT("socket_server_thread(): Listen failed.", 0);
}
for (;;) {
p_clientcb->socket = accept(listenfd,
(struct sockaddr *) &p_clientcb->cliaddr,
&p_clientcb->clilen);
if (p_clientcb->socket < 0) {
mem_free(p_clientcb);
} else {
/* Keep this tecb in our list */
p_clientcb->ssl = wolfSSL_new(ctx);
LWIP_ASSERT("wolfSSL_new() failed.", p_clientcb->ssl != NULL);
wolfSSL_set_fd(p_clientcb->ssl, p_clientcb->socket);
p_clientcb->next = clientcb_list;
clientcb_list = p_clientcb;
}
}