<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[wolfSSL - Embedded SSL Library — [SOLVED] wolfSSL_connect() returns with error:40]]></title>
		<link>https://www.wolfssl.com/forums/topic1462-solved-wolfsslconnect-returns-with-error40.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic1462.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in [SOLVED] wolfSSL_connect() returns with error:40.]]></description>
		<lastBuildDate>Tue, 26 Nov 2019 16:05:11 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: [SOLVED] wolfSSL_connect() returns with error:40]]></title>
			<link>https://www.wolfssl.com/forums/post4970.html#p4970</link>
			<description><![CDATA[<p>Hi burakkirazli,</p><p>Thanks for letting us know the fix was due to not having XREALLOC / realloc implemented correctly when using the normal math.</p><p>David Garske, wolfSSL</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Tue, 26 Nov 2019 16:05:11 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4970.html#p4970</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] wolfSSL_connect() returns with error:40]]></title>
			<link>https://www.wolfssl.com/forums/post4969.html#p4969</link>
			<description><![CDATA[<p>Hi Dgarske, </p><p>I found the actual reason of why my setup failed.</p><p>One of my configuration uses realloc. I did not implemented realloc and existing setup was using standart realloc. I implemented it and it works.</p><p>Thanks.</p>]]></description>
			<author><![CDATA[null@example.com (burakkirazli)]]></author>
			<pubDate>Tue, 26 Nov 2019 10:50:10 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4969.html#p4969</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] wolfSSL_connect() returns with error:40]]></title>
			<link>https://www.wolfssl.com/forums/post4968.html#p4968</link>
			<description><![CDATA[<p>Hi burakkirazli,</p><p>Error -142 is `ASN_GETINT_E`. Happening on call to `wc_RsaPublicKeyDecode`. My best guess is you heap allocation failed when trying to parse the RSA certificate from the peer. Check your heap space and either make more available or switch to a stack based math by defining USE_FAST_MATH. It might be helpful to look at this example user_settings.h file, which describes many build options. <a href="https://github.com/wolfSSL/wolfssl/blob/master/IDE/GCC-ARM/Header/user_settings.h">https://github.com/wolfSSL/wolfssl/blob … settings.h</a></p><p>Thanks,<br />David Garske, wolfSSL</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Mon, 25 Nov 2019 22:55:04 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4968.html#p4968</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] wolfSSL_connect() returns with error:40]]></title>
			<link>https://www.wolfssl.com/forums/post4963.html#p4963</link>
			<description><![CDATA[<p>I changed my configuration to these:</p><p><strong>#define SINGLE_THREADED<br />#define FREERTOS<br />#define NO_FILESYSTEM<br />#define WOLFSSL_NO_SOCK<br />#define WOLFSSL_USER_IO<br />#define NO_DEV_RANDOM<br />#define NO_WRITEV<br />#define WC_NO_HARDEN</strong></p><p><strong>#define HAVE_HASHDRBG<br />#define HAVE_HKDF<br />#define HAVE_AESCCM<br />#define HAVE_AESGCM<br />#define HAVE_CHACHA<br />#define HAVE_POLY1305<br />#define HAVE_ONE_TIME_AUTH<br />#define HAVE_CAMELLIA<br />#define HAVE_SRP<br />#define HAVE_ECC<br />#define HAVE_CURVE25519<br />#define HAVE_ED25519<br />#define WOLFSSL_TLS12<br />#define HAVE_TLS_EXTENSIONS<br />#define HAVE_SUPPORTED_CURVES<br />#define HAVE_HKDF<br />#define WC_RSA_PSS<br />#define NO_OLD_TLS<br />#define HAVE_SHA512<br />#define WOLFSSL_SHA512</strong></p><p><strong>#define WOLFSSL_STM32F4<br />#define NO_STM32_CRYPTO<br />#define NO_STM32_HASH<br />#define NO_INLINE<br />#define WOLFSSL_IGNORE_FILE_WARN<br />#define NO_ASN_TIME</strong></p><p><strong>#define DEBUG_WOLFSSL<br /></strong></p><br /><p>wolfSSL Entering wolfSSL_Init<br />wolfSSL Entering wolfCrypt_Init<br />wolfSSL Entering TLSv1_2_client_method_ex<br />wolfSSL Entering wolfSSL_CTX_new_ex<br />wolfSSL Entering wolfSSL_CertManagerNew<br />wolfSSL Leaving WOLFSSL_CTX_new, return 0<br />wolfSSL Entering wolfSSL_CTX_load_verify_buffer_ex<br />Processing CA PEM file<br />wolfSSL Entering PemToDer<br />Adding a CA<br />wolfSSL Entering GetExplicitVersion<br />wolfSSL Entering GetSerialNumber<br />Got Cert Header<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Algo ID<br />Getting Cert Name<br />Getting Cert Name<br />Got Subject Name<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Key<br />Parsed Past Key<br />wolfSSL Entering DecodeCertExtensions<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeSubjKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeAuthKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeBasicCaConstraint<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />&nbsp; &nbsp; &nbsp; &nbsp; Parsed new CA<br />&nbsp; &nbsp; &nbsp; &nbsp; Freeing Parsed CA<br />&nbsp; &nbsp; &nbsp; &nbsp; Freeing der CA<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OK Freeing der CA<br />wolfSSL Leaving AddCA, return 0<br />&nbsp; &nbsp;Processed a CA<br />Processed at least one valid CA. Other stuff OK<br />wolfSSL Entering wolfSSL_CTX_load_verify_buffer_ex<br />Processing CA PEM file<br />wolfSSL Entering PemToDer<br />Adding a CA<br />wolfSSL Entering GetExplicitVersion<br />wolfSSL Entering GetSerialNumber<br />Got Cert Header<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Algo ID<br />Getting Cert Name<br />Getting Cert Name<br />Got Subject Name<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Key<br />Parsed Past Key<br />wolfSSL Entering DecodeCertExtensions<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeSubjKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeAuthKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeBasicCaConstraint<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />&nbsp; &nbsp; &nbsp; &nbsp; Parsed new CA<br />&nbsp; &nbsp; &nbsp; &nbsp; Already have this CA, not adding again<br />&nbsp; &nbsp; &nbsp; &nbsp; Freeing Parsed CA<br />&nbsp; &nbsp; &nbsp; &nbsp; Freeing der CA<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OK Freeing der CA<br />wolfSSL Leaving AddCA, return 0<br />&nbsp; &nbsp;Processed a CA<br />Processed at least one valid CA. Other stuff OK<br />wolfSSL Entering SSL_new<br />wolfSSL Leaving SSL_new, return 0<br />wolfSSL Entering SSL_connect()<br />wolfSSL Entering SendClientHello<br />Adding signature algorithms extension<br />growing output buffer</p><p>Signature Algorithms extension to write<br />Point Formats extension to write<br />Supported Groups extension to write<br />TASK.cpp: TLS Send Callback</p><p>DEBUG-asyncio 134 bytes transmit</p><p>Shrinking output buffer</p><p>wolfSSL Leaving SendClientHello, return 0<br />connect state: CLIENT_HELLO_SENT<br />wolfSSL error occurred, error = -323<br />DEBUG-asyncio 2337 bytes received<br />wolfSSL Entering SSL_connect()<br />wolfSSL error occurred, error = -323<br />wolfSSL Entering SSL_connect()<br />TASK.cpp: TLS data read 5 bytes.<br />growing input buffer</p><p>TASK.cpp: TLS data read 84 bytes.<br />received record layer msg<br />wolfSSL Entering DoHandShakeMsg()<br />wolfSSL Entering DoHandShakeMsgType<br />processing server hello<br />wolfSSL Entering DoServerHello<br />Point Formats extension received<br />wolfSSL Entering VerifyClientSuite<br />wolfSSL Leaving DoServerHello, return 0<br />Shrinking input buffer</p><p>wolfSSL Leaving DoHandShakeMsgType(), return 0<br />wolfSSL Leaving DoHandShakeMsg(), return 0<br />TASK.cpp: TLS data read 5 bytes.<br />growing input buffer</p><p>TASK.cpp: TLS data read 1929 bytes.<br />received record layer msg<br />wolfSSL Entering DoHandShakeMsg()<br />wolfSSL Entering DoHandShakeMsgType<br />processing certificate<br />wolfSSL Entering DoCertificate<br />wolfSSL Entering ProcessPeerCerts<br />Loading peer&#039;s cert chain<br />&nbsp; &nbsp; &nbsp; &nbsp; Put another cert into chain<br />&nbsp; &nbsp; &nbsp; &nbsp; Put another cert into chain<br />wolfSSL Entering GetExplicitVersion<br />wolfSSL Entering GetSerialNumber<br />Got Cert Header<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Algo ID<br />Getting Cert Name<br />Getting Cert Name<br />Got Subject Name<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Key<br />Parsed Past Key<br />wolfSSL Entering DecodeCertExtensions<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeSubjKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeAuthKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeBasicCaConstraint<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />About to verify certificate signature<br />wolfSSL Entering ConfirmSignature<br />ASN Key decode error RSA<br />wolfSSL Leaving ConfirmSignature, return -142<br />Confirm signature failed<br />Failed to verify CA from chain<br />growing output buffer</p><p>TASK.cpp: TLS Send Callback<br />DEBUG-asyncio 7 bytes transmit<br />Shrinking output buffer</p><p>Verifying Peer&#039;s cert<br />wolfSSL Entering GetExplicitVersion<br />wolfSSL Entering GetSerialNumber<br />Got Cert Header<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Algo ID<br />Getting Cert Name<br />Getting Cert Name<br />Got Subject Name<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Key<br />Parsed Past Key<br />wolfSSL Entering DecodeCertExtensions<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeBasicCaConstraint<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeKeyUsage<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeSubjKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeAuthKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeAltNames<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />About to verify certificate signature<br />wolfSSL Entering ConfirmSignature<br />ASN Key decode error RSA<br />wolfSSL Leaving ConfirmSignature, return -142<br />Confirm signature failed<br />Failed to verify Peer&#039;s cert<br />&nbsp; &nbsp; &nbsp; &nbsp; No callback override available, fatal<br />wolfSSL Leaving ProcessPeerCerts, return -142<br />wolfSSL Leaving DoCertificate, return -142<br />wolfSSL Leaving DoHandShakeMsgType(), return -142<br />wolfSSL Leaving DoHandShakeMsg(), return -142<br />wolfSSL error occurred, error = -142<br />wolfSSL error occurred, error = -142<br />wolfSSL Entering SSL_connect()<br />ProcessReply retry in error state, not allowed<br />wolfSSL error occurred, error = -142</p>]]></description>
			<author><![CDATA[null@example.com (burakkirazli)]]></author>
			<pubDate>Fri, 22 Nov 2019 07:44:55 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4963.html#p4963</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] wolfSSL_connect() returns with error:40]]></title>
			<link>https://www.wolfssl.com/forums/post4962.html#p4962</link>
			<description><![CDATA[<p>Hi David, </p><p>Chipher suite:</p><p>DHE-RSA-AES128-SHA:<br />DHE-RSA-AES256-SHA:<br />DHE-PSK-AES128-CBC-SHA256:<br />DHE-RSA-AES128-SHA256:<br />DHE-RSA-AES256-SHA256:<br />EDH-RSA-DES-CBC3-SHA</p><br /><p>My configuration:</p><p>#define SINGLE_THREADED<br />#define FREERTOS<br />#define NO_FILESYSTEM<br />#define WOLFSSL_NO_SOCK<br />#define WOLFSSL_USER_IO<br />#define NO_DEV_RANDOM<br />#define NO_WRITEV<br />#define WC_NO_HARDEN</p><p>//#define HAVE_ECC<br />#define HAVE_DH<br />#define HAVE_ED25519<br />#define HAVE_SHA512<br />#define WOLFSSL_SHA512<br />#define WOLFSSL_STM32F4<br />#define NO_STM32_CRYPTO<br />#define NO_STM32_HASH<br />#define NO_INLINE<br />#define WOLFSSL_IGNORE_FILE_WARN<br />#define NO_ASN_TIME</p><br /><p>I attached what is transmitted to the server as binary output. Unfortunately, i can not use wireshark at this platform.</p>]]></description>
			<author><![CDATA[null@example.com (burakkirazli)]]></author>
			<pubDate>Fri, 22 Nov 2019 07:14:45 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4962.html#p4962</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] wolfSSL_connect() returns with error:40]]></title>
			<link>https://www.wolfssl.com/forums/post4961.html#p4961</link>
			<description><![CDATA[<p>Hi burakkirazli,</p><p>Looks like the TLS server did not like something in the client_hello and sent back an alert 40 (handshake_failure). Can you describe more about the server and what build options you are using? Perhaps you can send a Wireshark trace and print a run-time list of enabled cipher suites?</p><div class="codebox"><pre><code>#ifndef WOLFSSL_CIPHER_LIST_MAX_SIZE
    #define WOLFSSL_CIPHER_LIST_MAX_SIZE 4096
#endif
static void ShowCiphers(void)
{
    char ciphers[WOLFSSL_CIPHER_LIST_MAX_SIZE];
    int ret = wolfSSL_get_ciphers(ciphers, (int)sizeof(ciphers));

    if (ret == WOLFSSL_SUCCESS)
        printf(&quot;%s\n&quot;, ciphers);
}</code></pre></div><p>Thanks,<br />David Garske, wolfSSL</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Thu, 21 Nov 2019 20:30:31 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4961.html#p4961</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] wolfSSL_connect() returns with error:40]]></title>
			<link>https://www.wolfssl.com/forums/post4960.html#p4960</link>
			<description><![CDATA[<p>I am trying to connect to a remote server. My trying is successful with bsd sockets on my linux machines, but not in my cortex-M.</p><p>The init code is like:</p><div class="codebox"><pre><code>wolfSSL_Debugging_ON();

/*Init library.*/
wolfSSL_Init();

/*Init context.*/
auto&amp; tls = m_ctx.client.tls;
tls.ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method());

/*Init verification buffer.*/
auto success = wolfSSL_CTX_load_verify_buffer(tls.ctx, (unsigned char*)cert_get(), cert_get_len(), SSL_FILETYPE_PEM);
ASSERT(success == WOLFSSL_SUCCESS);

/* Setup the async IO callbacks */
wolfSSL_CTX_SetIORecv(tls.ctx, tls_receive);
wolfSSL_CTX_SetIOSend(tls.ctx, tls_send);


/*Create TLS handle.*/
tls.ssl = wolfSSL_new(tls.ctx);
ASSERT(tls.ssl != nullptr);</code></pre></div><br /><p>The loop code like:</p><div class="codebox"><pre><code>auto rc = wolfSSL_connect(me-&gt;_ctx.client.tls.ssl);</code></pre></div><br /><p><strong>Debug output:</strong></p><p><strong>Getting Cert Name<br />Getting Cert Name<br />Got Subject Name<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />Got Key<br />Parsed Past Key<br />wolfSSL Entering DecodeCertExtensions<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeSubjKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeAuthKeyId<br />wolfSSL Entering GetObjectId()<br />wolfSSL Entering DecodeBasicCaConstraint<br />wolfSSL Entering GetAlgoId<br />wolfSSL Entering GetObjectId()<br />&nbsp; &nbsp; &nbsp; &nbsp; Parsed new CA<br />&nbsp; &nbsp; &nbsp; &nbsp; Freeing Parsed CA<br />&nbsp; &nbsp; &nbsp; &nbsp; Freeing der CA<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OK Freeing der CA<br />wolfSSL Leaving AddCA, return 0<br />&nbsp; &nbsp;Processed a CA<br />Processed at least one valid CA. Other stuff OK</strong></p><p><strong>DEBUG: asyncio 72 bytes transmit</strong></p><p><strong>Shrinking output buffer<br />wolfSSL Leaving SendClientHello, return 0<br />connect state: CLIENT_HELLO_SENT<br />wolfSSL error occurred, error = -323<br />wolfSSL Entering SSL_connect()</strong></p><p><strong>DEBUG: asyncio 7 bytes received</strong></p><p><strong>wolfSSL Entering SSL_connect()<br />wolfSSL error occurred, error = -323<br />wolfSSL Entering SSL_connect()<br />mqtt_manager.cpp: TLS data read 5 bytes.<br />mqtt_manager.cpp: TLS data read 2 bytes.<br />received record layer msg<br />got ALERT!<br />Got alert<br />wolfSSL error occurred, error = 40<br />wolfSSL error occurred, error = -313<br />wolfSSL Entering SSL_connect()<br />ProcessReply retry in error state, not allowed<br />wolfSSL error occurred, error = -313<br /></strong></p><p>IO under wolfssl is running in an async manner.</p>]]></description>
			<author><![CDATA[null@example.com (burakkirazli)]]></author>
			<pubDate>Thu, 21 Nov 2019 19:57:58 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4960.html#p4960</guid>
		</item>
	</channel>
</rss>
