<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 4, 2017 at 10:27 AM, Kyle Hamilton <span dir="ltr"><<a href="mailto:aerowolf@gmail.com" target="_blank">aerowolf@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">SSL alert number 48 is specified in the documents that define SSL/TLS.<br>
It is the code for "unknown_ca", which means that verification failed<br>
because it didn't get set up with the correct CA to verify against.<br>
You might wish to look up SSL_CTX_load_verify_locations(<wbr>3).  There may<br>
also be other API calls which can load the context with certificates<br>
to verify against.<br></blockquote><div><br></div><div>Ok I understand that, but what could be wrong with the certificates that I generate with the commands that I told in the previous message?</div><div><br></div><div>Kind regards.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
You can get a list of the alert numbers from RFC 5246, available from<br>
(among other places) <a href="https://www.ietf.org/rfc/rfc5246.txt" rel="noreferrer" target="_blank">https://www.ietf.org/rfc/<wbr>rfc5246.txt</a> (also<br>
available as a PDF from <a href="https://www.ietf.org/rfc/rfc5246.txt.pdf" rel="noreferrer" target="_blank">https://www.ietf.org/rfc/<wbr>rfc5246.txt.pdf</a>).<br>
<br>
-Kyle H<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Dec 4, 2017 at 12:10 AM,  <<a href="mailto:wizard2010@gmail.com">wizard2010@gmail.com</a>> wrote:<br>
> Hi ,<br>
><br>
> Please see in attach the files that I'm using.<br>
> I generate the certificates with the following commands:<br>
><br>
> ## Create CA<br>
> openssl genrsa -out ca.key 4096<br>
> openssl req -new -x509 -days 365 -key ca.key -out ca.crt<br>
> openssl x509 -in ca.crt -out ca.pem -outform PEM<br>
><br>
> ## Create the Server Key and CSR<br>
> openssl genrsa -out server.key 4096<br>
> openssl req -new -key server.key -out server.csr<br>
> openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key<br>
> -set_serial 01 -out server.crt<br>
> openssl x509 -in server.crt -out server.pem -outform PEM<br>
><br>
> ## Create the Client Key and CSR<br>
> openssl genrsa -out client.key 4096<br>
> openssl req -new -key client.key -out client.csr<br>
> openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key<br>
> -set_serial 01 -out client.crt<br>
> openssl x509 -in client.crt -out client.pem -outform PEM<br>
><br>
><br>
> I left the default value of each question that openssl ask when it's<br>
> creating the certificates like Country, City, CN, etc. Like this way:<br>
>><br>
>> openssl req -new -key server.key -out server.csr<br>
>><br>
>> You are about to be asked to enter information that will be incorporated<br>
>><br>
>> into your certificate request.<br>
>><br>
>> What you are about to enter is what is called a Distinguished Name or a<br>
>> DN.<br>
>><br>
>> There are quite a few fields but you can leave some blank<br>
>><br>
>> For some fields there will be a default value,<br>
>><br>
>> If you enter '.', the field will be left blank.<br>
>><br>
>> -----<br>
>><br>
>> Country Name (2 letter code) [AU]:<br>
>><br>
>> State or Province Name (full name) [Some-State]:<br>
>><br>
>> Locality Name (eg, city) []:<br>
>><br>
>> Organization Name (eg, company) [Internet Widgits Pty Ltd]:<br>
>><br>
>> Organizational Unit Name (eg, section) []:<br>
>><br>
>> Common Name (e.g. server FQDN or YOUR name) []:<br>
>><br>
>> Email Address []:<br>
>><br>
>> Please enter the following 'extra' attributes<br>
>><br>
>> to be sent with your certificate request<br>
>><br>
>> A challenge password []:<br>
>><br>
>> An optional company name []:<br>
><br>
><br>
> Thanks.<br>
> Kind regards.<br>
><br>
><br>
> On Thu, Nov 30, 2017 at 2:45 PM, Jan Just Keijser <<a href="mailto:janjust@nikhef.nl">janjust@nikhef.nl</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> On 29/11/17 14:37, <a href="mailto:wizard2010@gmail.com">wizard2010@gmail.com</a> wrote:<br>
>><br>
>> Hi JJK,<br>
>><br>
>> I test you function and I've got this result:<br>
>>><br>
>>> ok = 0<br>
>>> cert DN: /C=AU/ST=Some-State/O=Internet Widgits Pty Ltd<br>
>>> ok = 1<br>
>>> cert DN: /C=AU/ST=Some-State/O=Internet Widgits Pty Ltd<br>
>><br>
>><br>
>> Why I see this 2 time?<br>
>> When I create the certificates I didn't fill with any special information,<br>
>> just type enter in every question that is made. Did you think this could<br>
>> cause this issue?<br>
>><br>
>><br>
>> what you should have seen is the certificate stack, starting with the CA,<br>
>> and then the client cert, e.g.<br>
>><br>
>> Connection accept...<br>
>> ok = 1<br>
>> cert DN: /C=US/O=Cookbook 2.4/CN=Cookbook 2.4<br>
>> CA/emailAddress=<a href="mailto:openvpn@example.com">openvpn@<wbr>example.com</a><br>
>> ok = 1<br>
>> cert DN: /C=US/O=Cookbook 2.4/CN=client1<br>
>><br>
>><br>
>> so I suspect that your ca.crt on the server side is not specified<br>
>> correctly.<br>
>> You may also send me your ca.crt, server.{crt,key} and client.{crt,key}<br>
>> files privately, and I will run the same test using your set of<br>
>> certificates.<br>
>><br>
>> HTH,<br>
>><br>
>> JJK<br>
>><br>
>><br>
>><br>
>><br>
>> On Wed, Nov 29, 2017 at 8:56 AM, Jan Just Keijser <<a href="mailto:janjust@nikhef.nl">janjust@nikhef.nl</a>><br>
>> wrote:<br>
>>><br>
>>> Hi,<br>
>>><br>
>>> On 28/11/17 11:03, <a href="mailto:wizard2010@gmail.com">wizard2010@gmail.com</a> wrote:<br>
>>><br>
>>> Hi there.<br>
>>><br>
>>> I guess my problem is really related to verify callback on<br>
>>> SSL_CTX_set_verify function.<br>
>>> I just add to my code a dummy callback returning 1 and everything works<br>
>>> properly.<br>
>>><br>
>>>><br>
>>>> int verify_callback (int ok, X509_STORE_CTX *ctx);<br>
>>>> int verify_callback (int ok, X509_STORE_CTX *ctx)<br>
>>>> {<br>
>>>>     printf("Verification callback OK!\n");<br>
>>>>     return 1;<br>
>>>> }<br>
>>>> ...<br>
>>>> SSL_CTX_set_verify(ssl_server_<wbr>ctx, SSL_VERIFY_PEER |<br>
>>>> SSL_VERIFY_FAIL_IF_NO_PEER_<wbr>CERT, dtls_verify_callback);<br>
>>>> ...<br>
>>><br>
>>><br>
>>> The problem is that error don't tell much information about what's really<br>
>>> going on or what's really missing.<br>
>>> Thanks for your help.<br>
>>><br>
>>> Now you've effectively disabled all security :)<br>
>>><br>
>>> Try adding this to the verify_callback<br>
>>><br>
>>><br>
>>> static int verify_callback(int ok, X509_STORE_CTX *ctx)<br>
>>> {<br>
>>>     X509           *cert = NULL;<br>
>>>     char           *cert_DN = NULL;<br>
>>><br>
>>>     printf("ok = %d\n", ok);<br>
>>>     cert    = X509_STORE_CTX_get_current_<wbr>cert(ctx);<br>
>>>     cert_DN = X509_NAME_oneline( X509_get_subject_name( cert ), NULL, 0<br>
>>> );<br>
>>>     printf( "cert DN: %s\n", cert_DN);<br>
>>><br>
>>> }<br>
>>><br>
>>><br>
>>> that way, you will know whether your server is processing the right<br>
>>> certificate chain.<br>
>>><br>
>>> HTH,<br>
>>><br>
>>> JJK<br>
>>><br>
>><br>
>><br>
><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> --<br>
> openssl-users mailing list<br>
> To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><br>
><br>
</div></div></blockquote></div><br></div></div>