<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=koi8-r"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@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:11.0pt;
        font-family:"Calibri","sans-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
        {mso-style-priority:99;
        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";}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"๓ิมฮฤมาิฮูส HTML ๚ฮมห";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTML
        {mso-style-name:"๓ิมฮฤมาิฮูส HTML ๚ฮมห";
        mso-style-priority:99;
        mso-style-link:"๓ิมฮฤมาิฮูส HTML";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:2.0cm 42.5pt 2.0cm 3.0cm;}
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=RU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal style='margin-bottom:12.0pt;line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:"Arial","sans-serif";color:black'>Spent all night trying to establish SSL connection from my Erlang program to Nagios NRPE service. <o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt;line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:"Arial","sans-serif";color:black'>This is kind of excerpt from <b>check_nrpe</b> code which connects just fine:<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>SSL_library_init();<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>SSLeay_add_ssl_algorithms();<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>meth=SSLv23_client_method();<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>SSL_load_error_strings();<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>ctx=SSL_CTX_new(meth));<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>SSL_CTX_set_options(ctx,SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>result=my_tcp_connect(server_name,server_port,&sd);<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>/* do SSL handshake */<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>if(result==STATE_OK && use_ssl==TRUE){<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>š if((ssl=SSL_new(ctx))!=NULL){<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>ššš SSL_CTX_set_cipher_list(ctx,"ADH");<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>ššš SSL_set_fd(ssl,sd);<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>ššš rc=SSL_connect(ssl));<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>š }<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>}<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt;line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:"Arial","sans-serif";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt;line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:"Arial","sans-serif";color:black'>But I couldn't establish connection in any way. I always got an error:<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>Erlang R16B (erts-5.10) [source] [64-bit] [smp:1:1] [async-threads:0] [hipe] [kernel-poll:false] <o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>Eshell V5.10<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'><o:p> </o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>5> SockOpts.<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>[{active,false},<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'> {ssl_imp,old},<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'> {verify,verify_none},<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'> {ciphers,[{dh_anon,rc4_128,md5},<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>šššššššššš {dh_anon,des_cbc,sha},<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>šššššššššš {dh_anon,'3des_ede_cbc',sha},<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>šššššššššš {dh_anon,aes_128_cbc,sha},<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>šššššššššš {dh_anon,aes_256_cbc,sha}]}]<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>6> ssl:connect( Ip, 5666, SockOpts, infinity).<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'><o:p> </o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>=ERROR REPORT==== 16-Jan-2012::12:49:23 ===<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>SSL: hello: ssl_handshake.erl:885:Fatal error: handshake failure<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>{error,esslconnect}<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt;line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:"Arial","sans-serif";color:black'>Code in ssl_handshake.erl at line 885 is<o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>dec_hs( _, _ ) -> <o:p></o:p></span></p><p class=MsoNormal style='line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>ššššthrow( ?ALERT_REC( ... ) )<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt;line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:"Arial","sans-serif";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt;line-height:13.5pt;background:white;vertical-align:baseline'><span lang=EN-US style='font-size:10.5pt;font-family:"Arial","sans-serif";color:black'>What do you think is it possible to make this type of connection in Erlang? What else can I try or is it a bug?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>