<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-IN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hi Techi,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Option
</span><span style="font-family:"Calibri",sans-serif;color:black">-DLWS_OPENSSL_CLIENT_CERTS should work  Please find the following, 
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">      
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F;mso-fareast-language:EN-US">/*
<u>openssl</u> <u>init</u> for <u>cert</u> verification (for client sockets) */</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">      
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055;mso-fareast-language:EN-US">if</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US"> (!info-></span><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0;mso-fareast-language:EN-US">ssl_ca_filepath</span><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">)
 {</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">             
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055;mso-fareast-language:EN-US">if</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US"> (!SSL_CTX_load_verify_locations(</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">                     context-></span><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0;mso-fareast-language:EN-US">ssl_client_ctx</span><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">,
 NULL,</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">                                      
<span style="background:silver;mso-highlight:silver">LWS_OPENSSL_CLIENT_CERTS</span>))</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">                     lwsl_err(</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">                        
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF;mso-fareast-language:EN-US">"Unable to load SSL Client
<u>certs</u> from %s "</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">                        
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF;mso-fareast-language:EN-US">"(set by --with-client-<u>cert</u>-<u>dir</u>= "</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">                        
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF;mso-fareast-language:EN-US">"in configure) --  client
<u>ssl</u> isn't "</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">                        
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF;mso-fareast-language:EN-US">"going to work"</span><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">,
<span style="background:silver;mso-highlight:silver">LWS_OPENSSL_CLIENT_CERTS</span>);</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US">So make sure that if you have multiple CA’s don’t set
<span style="color:black">info-></span><span style="color:#0000C0">ssl_ca_filepath, instead during compile time set MACRO
</span><span style="color:black;background:silver;mso-highlight:silver">LWS_OPENSSL_CLIENT_CERTS</span><span style="color:black"> to a directory
<o:p></o:p></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black;mso-fareast-language:EN-US">which contain all the required CA’s (including intermediate, if server Sends intermediate CA as chain during SSL handshake
 intermediate CA may not be required but Root CA should be there).</span><span style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Subi<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> techi eth [mailto:andy.green@linaro.org]
<br>
<b>Sent:</b> 05 January 2016 15:31<br>
<b>To:</b> Subi S S <andy.green@linaro.org><br>
<b>Cc:</b> libwebsockets@ml.libwebsockets.org<br>
<b>Subject:</b> Re: [Libwebsockets] Server cert verfication by client<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Thanks for input.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Is that call verify(SSL_get_verify_result) chain available in server certificate  ?<o:p></o:p></p>
</div>
<p class="MsoNormal">I have tried to use <span style="font-family:"Calibri",sans-serif;color:black">
-DLWS_OPENSSL_CLIENT_CERTS option due to multiple ca but i think openssl always taking cert from SSL_CERT_PATH (Path used by openssl)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Mon, Jan 4, 2016 at 9:33 AM, Subi S S <<a href="mailto:andy.green@linaro.org" target="_blank">andy.green@linaro.org</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">Hi Techi,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">When use_ssl is set to ‘1’  , server certificate will be verified by library itself using openssl ( see client.c)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                    lws_latency_pre(context, wsi);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                    n =
<span style="background:silver">SSL_get_verify_result</span>(wsi->ssl);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                    lws_latency(context, wsi,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                "SSL_get_verify_result LWS_CONNMODE..HANDSHAKE",</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                                                                      n, n > 0);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                    if ((n != X509_V_OK) && (</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                n != X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT ||</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                                                       wsi-><span style="background:blue">use_ssl</span> != 2)) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                lwsl_err(</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                      "server's
<u>cert</u> didn't look good %d\n", n);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                libwebsocket_close_and_free_session(context,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-family:"Calibri",sans-serif;color:black">                                                                        wsi,
<i>LWS_CLOSE_STATUS_NOSTATUS</i>);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">                                                return 0;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">If you want to override the openssl validation or you want to do host name validation etc, you can set your own openSSL
 call backs.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">for example
<span style="background:silver">SSL_CTX_set_cert_verify_callback</span> under LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">If you have multiple ca certs , you can set the directory path during libwebsocket compilation  for example -DLWS_OPENSSL_CLIENT_CERTS=/etc/cacerts/</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">There is also option to set a ca file during the  during ctx creation  ( set the path in ssl_ca_filepath attribute).</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">Thanks,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Calibri",sans-serif;color:black">Subi</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> techi
 eth [mailto:<a href="mailto:andy.green@linaro.org" target="_blank">andy.green@linaro.org</a>]
<br>
<b>Sent:</b> 31 December 2015 18:32<br>
<b>To:</b> <a href="mailto:libwebsockets@ml.libwebsockets.org" target="_blank">libwebsockets@ml.libwebsockets.org</a><br>
<b>Subject:</b> [Libwebsockets] Server cert verfication by client</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">In the case of encrypted ssl_connection (use_ssl = 1),if client needs to verify server certificate then what is the way to do the same.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I was just thinking LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS is used for same but I could not able to conclude.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">If this callback needs to be used then do i need to do similar logic done in OpenSSL_verify_callback function.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Techi<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
Libwebsockets mailing list<br>
<a href="mailto:Libwebsockets@ml.libwebsockets.org">Libwebsockets@ml.libwebsockets.org</a><br>
<a href="http://ml.libwebsockets.org/mailman/listinfo/libwebsockets" target="_blank">http://ml.libwebsockets.org/mailman/listinfo/libwebsockets</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>