<?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 — Get Client Cert from TLS Handshake]]></title>
		<link>https://www.wolfssl.com/forums/topic707-get-client-cert-from-tls-handshake.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic707.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Get Client Cert from TLS Handshake.]]></description>
		<lastBuildDate>Mon, 21 Sep 2015 20:48:55 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Get Client Cert from TLS Handshake]]></title>
			<link>https://www.wolfssl.com/forums/post2219.html#p2219</link>
			<description><![CDATA[<p>Hi cfarrin,</p><p>wolfSSL does currently have a function similar to that in &lt;wolfssl/ssl.h&gt;:</p><div class="codebox"><pre><code>WOLFSSL_EVP_PKEY* wolfSSL_X509_get_pubkey(WOLFSSL_X509* x509);</code></pre></div><p>This will return a WOLFSSL_EVP_PKEY structure pointer (ex: mykey), from which you could get the DER formatted public key from mykey-&gt;pkey.ptr of size mykey-&gt;pkey_sz.</p><p>Best Regards,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Mon, 21 Sep 2015 20:48:55 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2219.html#p2219</guid>
		</item>
		<item>
			<title><![CDATA[Re: Get Client Cert from TLS Handshake]]></title>
			<link>https://www.wolfssl.com/forums/post2186.html#p2186</link>
			<description><![CDATA[<p>Hi Solved It the following way:<br />WOLFSSL *s;<br />.<br />.</p><p>peerCert = wolfSSL_get_peer_certificate(s);<br />peer_derCertCnst=wolfSSL_X509_get_der(peerCert, &amp;peer_derCertSz);<br />XMEMCPY( peer_derCert, peer_derCertCnst, peer_derCertSz);<br />InitDecodedCert( &amp;cert, peer_derCert, peer_derCertSz, 0);<br />ret = ParseCert(&amp;cert, CERT_TYPE, NO_VERIFY, 0);<br />XMEMCPY(pubKey, cert.publicKey, cert.Pub.Key.Size);</p><p>However I do think a wolfSSL_X509_get_pubKey(peerCert, &amp;peer_pubKeySz);&nbsp; Should be added to ssl.c make things easier.&nbsp; Thanks for the Help.</p><p>char* wolfSSL_X509_get_pubKey(WOLFSSL_X509* x509, int *outSz)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; char *asciiStr = malloc(FOURK_BUF);<br />&nbsp; &nbsp; &nbsp; &nbsp; WOLFSSL_ENTER(&quot;wolfSSL_X509_get_pubKey&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; if (x509 == NULL || outSz == NULL)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return NULL;<br />&nbsp; &nbsp; &nbsp; &nbsp; *outSz = (int)x509-&gt;pubKey.length;<br />&nbsp; &nbsp; &nbsp; &nbsp; return x509-&gt;pubKey.buffer;<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p>]]></description>
			<author><![CDATA[null@example.com (cfarrin)]]></author>
			<pubDate>Fri, 04 Sep 2015 20:34:15 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2186.html#p2186</guid>
		</item>
		<item>
			<title><![CDATA[Re: Get Client Cert from TLS Handshake]]></title>
			<link>https://www.wolfssl.com/forums/post2182.html#p2182</link>
			<description><![CDATA[<p>Hi Thanks for the response How ever I still Have an issue.&nbsp; As you mentioned I looked at the myVerify example I Tried the following:</p><p>#include &lt;wolfssl/ssl.h&gt;<br />#include &lt;wolfssl/options.h&gt;</p><p>#include &lt;cyassl/openssl/ssl.h&gt;<br />#include &lt;wolfssl/test.h&gt;</p><p>.<br />.<br />.<br />.</p><br /><p>char* wolfSSL_X509_get_pubKey(WOLFSSL_X509* x509, int *outSz)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; char *asciiStr = malloc(FOURK_BUF);<br />&nbsp; &nbsp; &nbsp; &nbsp; WOLFSSL_ENTER(&quot;wolfSSL_X509_get_pubKey&quot;);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; if (x509 == NULL || outSz == NULL)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return NULL;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; *outSz = (int)x509-&gt;pubKey.length;<br />&nbsp; &nbsp; &nbsp; &nbsp; return x509-&gt;pubKey.buffer;<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>main{<br /> WOLFSSL_X509*&nbsp; &nbsp;peerCert;<br /> char peer_pubKey[FOURK_BUF];<br /> int&nbsp; peer_pubKeySz;<br /> WOLFSSL *s;</p><p>.<br />.<br />.<br /> nbytes = wolfSSL_read(s, buffer, 1024);<br /> peerCert = wolfSSL_get_peer_certificate(s);<br /> peer_pubKey=(char *)wolfSSL_X509_get_pubKey(peerCert, &amp;peer_pubKeySz);</p><p>However when I compile it I get -&gt;</p><p>SSL2CRL.c: In function ‘wolfSSL_X509_get_pubKey’:<br />SSL2CRL.c:147:20: error: dereferencing pointer to incomplete type<br />&nbsp; *outSz = (int)x509-&gt;pubKey.length;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^<br />SSL2CRL.c:148:13: error: dereferencing pointer to incomplete type<br />&nbsp; return x509-&gt;pubKey.buffer;</p><br /><p>For some reason the compiler is having some issues with the WOLFSSL_X509 Structure.&nbsp; Mi Guess is that I need to include another library but I do not know which one.&nbsp; Thanks for the help.</p><p>cafrrin</p>]]></description>
			<author><![CDATA[null@example.com (cfarrin)]]></author>
			<pubDate>Fri, 04 Sep 2015 02:38:51 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2182.html#p2182</guid>
		</item>
		<item>
			<title><![CDATA[Re: Get Client Cert from TLS Handshake]]></title>
			<link>https://www.wolfssl.com/forums/post2180.html#p2180</link>
			<description><![CDATA[<p>Hi cfarrin,</p><p>When calling wolfSSL_CTX_set_verify(), the optional third parameter allows an application to register a verify callback.&nbsp; By default, this callback only gets called upon verification failure.&nbsp; It can be switched to be called every time by defining WOLFSSL_ALWAYS_VERIFY_CB when compiling wolfSSL, ie:</p><div class="codebox"><pre><code>cd wolfssl-3.6.6
./configure &lt;options&gt; C_EXTRA_FLAGS=&quot;-DWOLFSSL_ALWAYS_VERIFY_CB&quot;
make</code></pre></div><p>Inside this callback, your application can inspect the peer certificate.&nbsp; You can look in &lt;wolfssl_root&gt;/wolfssl/test.h, myVerify() for an example.</p><p>Best Regards,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Thu, 03 Sep 2015 17:58:17 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2180.html#p2180</guid>
		</item>
		<item>
			<title><![CDATA[Get Client Cert from TLS Handshake]]></title>
			<link>https://www.wolfssl.com/forums/post2177.html#p2177</link>
			<description><![CDATA[<p>Hi,</p><p>I want to verify that the client certificate belongs to a particular user that is logging in into a system.&nbsp; Is there a way to get the client&#039;s public key or certificate from the TLS handshake so that I can cross check it against a database that holds the user name-pubicKey/Cert or something like that.&nbsp; &nbsp;I am already verifying the peer with wolfSSL_CTX_set_verify.&nbsp; However I am unable to match it to the user loggin to the publicKey/Certificate which which is done at a later stage in my uathentication system because I am unable to get the public/Key Cert from the handshake.&nbsp; For now I am sending the client certificate over the TLS link but it does not seem to be the most appropriate solution.&nbsp; Any Suggestions. </p><p>Thank you for all your help.</p><p>cfarrin</p>]]></description>
			<author><![CDATA[null@example.com (cfarrin)]]></author>
			<pubDate>Thu, 03 Sep 2015 02:09:22 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2177.html#p2177</guid>
		</item>
	</channel>
</rss>
