Re: Problem with signature verification on microchip embedded controller

2011-10-19 Thread Kenneth Goldman
Yes, you can verify 'by hand' by doing the raw public key operation,
stripping off the padding and OID (what you call the asn1 formatting), 
and then comparing the hashes.

When you say this is what I got from the PIC controller, I assume you
mean the result of applying the public key to the signature.  Since
you don't see the obvious 00 01 ff ... padding, there are three 
possibilities:

- you're using the wrong public key, or it got altered, or it's in the 
wrong 
format for the crypto library
- you're using the wrong signature, or it got altered
- the raw public key operation isn't working correctly, or you called it
incorrectly

It's not a hashing issue, since you don't see the padding.

 From: TSCOconan chu...@tsco.ca
 To: openssl-users@openssl.org, 
 Date: 10/18/2011 03:03 PM
 Subject: Problem with signature verification on microchip embedded 
controller
 Sent by: owner-openssl-us...@openssl.org
 
 
 Hi,
 
I'm trying to implement certificate signature verification 
(certificates
 are generated and signed using OpenSSL) on a Microchip pic controller. 
The
 Microchip PIC controller doesn't support OpenSSL libraries, but it does 
have
 an encryption/decryption function.  I was successful in getting a SSL
 connection between PIC controller and a web server.  My next step is to
 setup signature verification on the PIC controller. 
 
After reading PKCS#1 V2.1 RSA Cryptography Standard
 (http://www.rsa.com/rsalabs/node.asp?id=2125)
 I realized that encryption is essentially the same as signature 
verification
 and decryption is the same as signing.  More specifically both 
encryption
 and verification uses the public key and the following formula: m = s^e 
mod
 n.  Where s is the signature or the message, e is the public exponent, n 
is
 the modulus and m is the encrypted message or decoded signature. 
Therefore,
 I'm trying to use the encryption algorithm provided to perform signature
 verification.
 
 In order to verify the certificate, I generate the SHA1 hash of the
 certificate; Decode signature using CA's public key and encryption
 algorithm.  Remove the padding from the decoded signature, the result 
hash
 should be equal to the SHA1 hash of the certificate. 
 
 However, I cannot get the two hash values to be equal.  I tried to
 verify my assumption and PIC controller results using OpenSSL command 
line. 
 
  openssl rsautl -in signature.txt -verify -asn1parse -inkey pubkey.pem
 -pubin
db e8 c6 cb 78 19 3c 0f-fd 96 1c 4f ed bd b2 34 45 60 bf 65 
   this matches the hash value I'm getting from PIC controller
 
  openssl rsautl -verify -in signature.txt -inkey pubkey.pem -pubin -raw
 -hexdump
00 01 ff ff ff ff ff ff-ff ff ff ff 00 30 21 30 
09 06 05 2b 0e 03 02 1a-05 00 04 14 db e8 c6 cb 
78 19 3c 0f fd 96 1c 4f-ed bd b2 34 45 60 bf 65 
  I believe this is what I should get after decoding the signature. After
 removing ff paddings I'll end up with asn1 format of the certificate 
hash.
 
  However this is what I got from the PIC controller which is much 
different
   8e fb 62 0e 09 c8 0b 49 40 1f 4d 2d a7 7d d6 8c
   9b bc 95 e6 bc 98 4b 96 aa 74 e5 68 90 40 bf 43 
   b5 c5 02 6d ab e3 ad 7b e6 98 fd 10 22 af b9 fb
 
  This is my signature
   7951 9b3d 244a 37f6 86d7 dc02 dc18 3bb4 
   0f66 db3a a3c1 a254 5be5 11d3 a691 63ef 
   0cf2 ec59 c48b 25ad 8881 9ed2 5230 bcd6 
 
  This is my public key (I'm using a very small key just for testing, 
will
 make it larger once everything works)
   96 FE CB 59 37 AE 8C 9C 6C 7A 01 50 0F D6 4F B4 
   E2 EC 45 D1 88 4E 1F 2D B7 1E 4B AD 76 4D 1F F1
   B0 CD 09 6F E5 B7 43 CA F8 14 FE 31 B2 06 F8 7B
  Exponent is 01 00 01
 
   I'm wondering are my assumptions wrong that I cannot use encryption
 algorithm for decoding signature?  or I'm doing something else wrong. 
 
 Thank you for any help.



[Crypt::SSLeay] - 400 Bad request problems.

2011-10-19 Thread Mark Denzel
I've been completely stymied on a problem connecting to a HTTPS site via our
proxy server.  I've tried dozens of different work arounds I found on the
web and none seem to work and I think I've localized the problem down to an
environment variable not loading.

Here's the small script I'm running to test this out:
#!/usr/bin/perl
use strict;

$ENV{HTTPS_PROXY}='http://
proxy/';

use LWP::UserAgent;
use HTTP::Request::Common;
use Crypt::SSLeay;


my $ua = new LWP::UserAgent;
$ua-cookie_jar();
$ua-protocols_allowed(['http','https']);

$ua-env_proxy();

my $url = 'https://www.redhat.com';

my $res = $ua-get($url);
if($res-is_success)
{
print $res-as_string;
}
else
{
print FAILED: .$res-status_line;
print \n\n;
print $res-as_string;
}



If I include the line *$ua-env_proxy()* I get a '400 - Bad Request' error
from the proxy server.  The reason for this is because it is sending a GET
call instead of a CONNECT call.  This supposedly works on apache servers but
anywhere else, you need to have Crypt::SSLeay take over and do the proper
CONNECT call.  The instructions on this are to set the
*$ENV{HTTPS_PROXY}*variable as I have done and remove the call to
*$ua-env_proxy()*.  This should then use Crypt::SSLeay and do a CONNECT.
When I make this change, I get a 500 error because it can't find the proxy.
I have also tried setting my Windows environment variable for HTTPS_PROXY
and proved it is set but the script still doesn't see it.  I can connect to
https sites without an issue via FireFox.  Is there something simple I'm
missing to force the script to use the environment variable HTTPS_PROXY?

any help would be much appreciated,

regards,

  Mark


-- 
Mark Denzel
Black Belt
Converged Computing Group
Motorola Mobility
w/m: 815-531-7621


Re: SSL documentation

2011-10-19 Thread Jakob Bohm

On 10/19/2011 6:10 AM, Mohan Radhakrishnan wrote:


Hi,

Is there any material available that shows flows of one-way/two-ssl 
and different types of CA architectures ? We use two-way SSL and 
generate CSR’s and update expired certificates and we are aware of the 
basic points.



I am not sure what you mean by one-way SSL.

The current SSL versions (those later than SSL3) are called TLS and are
specified in much detail in internet RFCs (http://www.rfc-editor.org or any
of their many mirror sites).

SSL does not deal with CSRs at all, those are used for CA operations
and obtaining certificates, in which case you should be looking at the
X.509 standards (from ITU) and the PKIX standards (also specified in
RFCs, see above).


I have browsed the NIST website.


NIST generally refers to the public/industry standards (see above) for
certificate and SSL/TLS operations, but do occasionally issue
documents that specify the required/permitted sets of options,
algorithms, key sizes etc. for Government work.


P.S.
Your standard e-mail disclaimer needs to be different for public
unofficial messages, such as mailing list postings.


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


How to recover Self signed SSL private Key Pass Phrase

2011-10-19 Thread raki42

Hi all

I had generated SSL self signed certificates and deployed on m system, where
i had saved m passphrase. Like 5 months back.

Now i am unable to find the document where i had saved passphrase , and
unable to retireve the Pass phrase for the SSL certificates

can any one please help me regarding this, like how to retrieve the SSL pass
phrase , or assign a new pass phrase for the same private key.
-- 
View this message in context: 
http://old.nabble.com/How-to-recover-Self-signed-SSL-private-Key-Pass-Phrase-tp32681015p32681015.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


getting the input not from command line

2011-10-19 Thread prabhu kalyan rout
Hi,
As per my project requirement i should configure the openssl req
command in such a way that it will not ask the user information from
prompt.
Is there any way so that i can directly pass the information in the
command line or through a file.

kindly help

Regards Prabhu
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: How to recover Self signed SSL private Key Pass Phrase

2011-10-19 Thread Jakob Bohm

The passphrase is used to actually encrypt the private key.

The only way is to try lots and lots of passphrases until you find the 
right one.


If you remember some parts of the passphrase (like It was one of my 
family members
birthday written backwards followed by the word TeaPot with some 
combination of upper
and lower case), then the number of possibilities is limited to a few 
hundred or thousand
possible passphrases, and you could create a small shell or perl script 
that tries them

all in less than a few days.

But if it was a good passphrase, and you really have no idea what it 
was, then there

is no realistic way to crack it.

On 10/19/2011 11:28 AM, raki42 wrote:

Hi all

I had generated SSL self signed certificates and deployed on m system, where
i had saved m passphrase. Like 5 months back.

Now i am unable to find the document where i had saved passphrase , and
unable to retireve the Pass phrase for the SSL certificates

can any one please help me regarding this, like how to retrieve the SSL pass
phrase , or assign a new pass phrase for the same private key.


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: getting the input not from command line

2011-10-19 Thread Jakob Bohm
Use the option -subj and adjust other settings in openssl.cnf to make 
things easier.


On 10/19/2011 2:43 PM, prabhu kalyan rout wrote:

Hi,
As per my project requirement i should configure the openssl req
command in such a way that it will not ask the user information from
prompt.
Is there any way so that i can directly pass the information in the
command line or through a file.

kindly help

Regards Prabhu
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: How to recover Self signed SSL private Key Pass Phrase

2011-10-19 Thread Mark Ridley
It was one of my family members
birthday written backwards followed by the word TeaPot with some
combination of upper
and lower case

Password of the year! :)

On 19 Oct, 2011, at 10:16 PM, Jakob Bohm jb-open...@wisemo.com wrote:

 It was one of my family members
 birthday written backwards followed by the word TeaPot with some combination 
 of upper
 and lower case
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


RE: How to recover Self signed SSL private Key Pass Phrase

2011-10-19 Thread Steffen DETTMER
 can any one please help me regarding this, like how to 
 retrieve the SSL pass phrase , or assign a new pass phrase 
 for the same private key.

Add all information you remember (possible parts, used characters,
length information) to a key cracking tool, run it and wait?









































End of message.
-- 

 
About Ingenico: Ingenico is a leading provider of payment, transaction and 
business solutions, with over 15 million terminals deployed in more than 125 
countries. Over 3,000 employees worldwide support merchants, banks and service 
providers to optimize and secure their electronic payments solutions, develop 
their offer of services and increase their point of sales revenue. 
http://www.ingenico.com/.
 This message may contain confidential and/or privileged information. If you 
are not the addressee or authorized to receive this for the addressee, you must 
not use, copy, disclose or take any action based on this message or any 
information herein. If you have received this message in error, please advise 
the sender immediately by reply e-mail and delete this message. Thank you for 
your cooperation.
 P Please consider the environment before printing this e-mail
 
 
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: getting the input not from command line

2011-10-19 Thread prabhu kalyan rout
Hi jakob,
Thanks for you help.

Can you please give me one example of the -subj option.

Thanks  Regards
Prabhu

On Wed, Oct 19, 2011 at 7:46 PM, Jakob Bohm jb-open...@wisemo.com wrote:
 Use the option -subj and adjust other settings in openssl.cnf to make things
 easier.

 On 10/19/2011 2:43 PM, prabhu kalyan rout wrote:

 Hi,
 As per my project requirement i should configure the openssl req
 command in such a way that it will not ask the user information from
 prompt.
 Is there any way so that i can directly pass the information in the
 command line or through a file.

 kindly help

 Regards Prabhu
 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-users@openssl.org
 Automated List Manager                           majord...@openssl.org

 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-users@openssl.org
 Automated List Manager                           majord...@openssl.org

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: getting the input not from command line

2011-10-19 Thread Jakob Bohm

There is almost an example on the documentation page for the req utility.

I have not used it myself, but it seems this would be a typical example:

-subj /DC=org/DC=OpenSSL/DC=users/CN=John Doe

On 10/19/2011 5:32 PM, prabhu kalyan rout wrote:

Hi jakob,
Thanks for you help.

Can you please give me one example of the -subj option.

Thanks  Regards
Prabhu

On Wed, Oct 19, 2011 at 7:46 PM, Jakob Bohmjb-open...@wisemo.com  wrote:

Use the option -subj and adjust other settings in openssl.cnf to make things
easier.

On 10/19/2011 2:43 PM, prabhu kalyan rout wrote:

Hi,
As per my project requirement i should configure the openssl req
command in such a way that it will not ask the user information from
prompt.
Is there any way so that i can directly pass the information in the
command line or through a file.

kindly help

Regards Prabhu
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Openssl version compatibility [0.9.8r vs. 1.0.0e]

2011-10-19 Thread Hasan Rezaul-CHR010
Hi All,

We have a bunch of Linux Boxes (Clients) that would run openssl 0.9.8r.

We will have a Solaris box (CA Server), that would run openssl 1.0.0e

Is there any compatibility problems that we would need to be concerned
about ? Is there any difference in functionality that could give rise to
unexpected problems ?

Thanks in advance for your help.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: getting the input not from command line

2011-10-19 Thread prabhu kalyan rout
Thanks jakob,
I am able to do it. now i have another problem.

The below command generate a signed certificate. but to generate it
ask for the user permission.
what i want is it will directly generate the certificate with out
asking the user permission. please find the command below.

openssl ca -in requests/garexWEB.CSR -cert ../CA/garexCA.CRT -keyfile
../CA/garexCA.KEY -out certificates/garexWEB.CRT

is there any way to do it.

Regards Prabhu

On Wed, Oct 19, 2011 at 9:26 PM, Jakob Bohm jb-open...@wisemo.com wrote:
 There is almost an example on the documentation page for the req utility.

 I have not used it myself, but it seems this would be a typical example:

 -subj /DC=org/DC=OpenSSL/DC=users/CN=John Doe

 On 10/19/2011 5:32 PM, prabhu kalyan rout wrote:

 Hi jakob,
 Thanks for you help.

 Can you please give me one example of the -subj option.

 Thanks  Regards
 Prabhu

 On Wed, Oct 19, 2011 at 7:46 PM, Jakob Bohmjb-open...@wisemo.com  wrote:

 Use the option -subj and adjust other settings in openssl.cnf to make
 things
 easier.

 On 10/19/2011 2:43 PM, prabhu kalyan rout wrote:

 Hi,
 As per my project requirement i should configure the openssl req
 command in such a way that it will not ask the user information from
 prompt.
 Is there any way so that i can directly pass the information in the
 command line or through a file.

 kindly help

 Regards Prabhu
 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-users@openssl.org
 Automated List Manager                           majord...@openssl.org

 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-users@openssl.org
 Automated List Manager                           majord...@openssl.org

 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-users@openssl.org
 Automated List Manager                           majord...@openssl.org

 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-users@openssl.org
 Automated List Manager                           majord...@openssl.org

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


RE: getting the input not from command line

2011-10-19 Thread Sergio NNX

Ciao.

If you use 'prompt = no' in openssl.conf, then it won't ask anything. I'm using 
it and it works ok!

Cheers.

Sergio.

 Date: Wed, 19 Oct 2011 22:25:57 +0530
 Subject: Re: getting the input not from command line
 From: pkr...@gmail.com
 To: openssl-users@openssl.org
 
 Thanks jakob,
 I am able to do it. now i have another problem.
 
 The below command generate a signed certificate. but to generate it
 ask for the user permission.
 what i want is it will directly generate the certificate with out
 asking the user permission. please find the command below.
 
 openssl ca -in requests/garexWEB.CSR -cert ../CA/garexCA.CRT -keyfile
 ../CA/garexCA.KEY -out certificates/garexWEB.CRT
 
 is there any way to do it.
 
 Regards Prabhu
 
 On Wed, Oct 19, 2011 at 9:26 PM, Jakob Bohm jb-open...@wisemo.com wrote:
  There is almost an example on the documentation page for the req utility.
 
  I have not used it myself, but it seems this would be a typical example:
 
  -subj /DC=org/DC=OpenSSL/DC=users/CN=John Doe
 
  On 10/19/2011 5:32 PM, prabhu kalyan rout wrote:
 
  Hi jakob,
  Thanks for you help.
 
  Can you please give me one example of the -subj option.
 
  Thanks  Regards
  Prabhu
 
  On Wed, Oct 19, 2011 at 7:46 PM, Jakob Bohmjb-open...@wisemo.com  wrote:
 
  Use the option -subj and adjust other settings in openssl.cnf to make
  things
  easier.
 
  On 10/19/2011 2:43 PM, prabhu kalyan rout wrote:
 
  Hi,
  As per my project requirement i should configure the openssl req
  command in such a way that it will not ask the user information from
  prompt.
  Is there any way so that i can directly pass the information in the
  command line or through a file.
 
  kindly help
 
  Regards Prabhu
  __
  OpenSSL Project http://www.openssl.org
  User Support Mailing Listopenssl-users@openssl.org
  Automated List Manager   majord...@openssl.org
 
  __
  OpenSSL Project http://www.openssl.org
  User Support Mailing Listopenssl-users@openssl.org
  Automated List Manager   majord...@openssl.org
 
  __
  OpenSSL Project http://www.openssl.org
  User Support Mailing Listopenssl-users@openssl.org
  Automated List Manager   majord...@openssl.org
 
  __
  OpenSSL Project http://www.openssl.org
  User Support Mailing Listopenssl-users@openssl.org
  Automated List Manager   majord...@openssl.org
 
 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing Listopenssl-users@openssl.org
 Automated List Manager   majord...@openssl.org
  

Re: test vectors for CTR DRBG

2011-10-19 Thread nimou


Jiri Hladky-2 wrote:
 
 Hello,
 
 I'm looking for the test vectors for CTR DRBG random number generator. I
 got
 test vectors from
 
  http://csrc.nist.gov/groups/STM/cavp/documents/drbg/drbgtestvectors.zip
 
 which contains  CTR_DRBG.rsp file. However, I'm looking for the following
 scenario which is not covered right now:
 
 [AES-128 no df]
 [PredictionResistance = False]
 [EntropyInputLen = 256]
 [NonceLen = 0]
 [PersonalizationStringLen = 0]
 [AdditionalInputLen = 0]
 
 Can anybody please provide such testing vectors?
 
 Thanks a lot!
 Jiri
 
 

Actually, you can use vectors from the following scenario : 

[AES-128 no df]
[PredictionResistance = False]
[EntropyInputLen = 256]
[NonceLen = 64]
[PersonalizationStringLen = 0]
[AdditionalInputLen = 0]

Here, it says that there is a nonce of length 64, but it is not used as
there is no nonce used when DF is not used... So even though this scenario
provides a nonce value, it is never used.

Trust me I tested it myself ! (you can also verify in SP800-90 that no nonce
is used when no df..)

Cheers !



Julien

-- 
View this message in context: 
http://old.nabble.com/test-vectors-for-CTR-DRBG-tp32446997p32683724.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Openssl version compatibility [0.9.8r vs. 1.0.0e]

2011-10-19 Thread Kenneth Goldman
 From: Hasan Rezaul-CHR010 rezaul.ha...@nsn.com
 To: openssl-users@openssl.org, 
 Date: 10/19/2011 12:44 PM
 Subject: Openssl version compatibility [0.9.8r  vs.  1.0.0e]
 Sent by: owner-openssl-us...@openssl.org
 
 We have a bunch of Linux Boxes (Clients) that would run openssl 0.9.8r.
 
 We will have a Solaris box (CA Server), that would run openssl 1.0.0e
 
 Is there any compatibility problems that we would need to be concerned
 about ? Is there any difference in functionality that could give rise to
 unexpected problems ?

It likely depends on the functions you're using.  I use AES, RSA,
and SHA and it works without source modification.

I strongly advise recompiling - even for letter changes.


SSL_OP_NO_QUERY_MTU problem in openssl 1.0.0.e

2011-10-19 Thread Oleg Moskalenko
Hi

I installed the new OpenSSL version and I immediately ran into a problem with 
DTLS: when the option SSL_OP_NO_QUERY_MTU is set, then the SSL_connect command 
produces a segmentation fault.

I am using Linux Ubuntu 11.04.

If I want to use my own discovered MTU, then I have to use that option. 
Otherwise, the system would ignore my MTU and use whatever the IP_MTU 
getsockopt on UDP socket returns.

Unfortunately, I am using different platforms, and MTU discovery is supported 
in OpenSSL only on Linux platform. I need it working on FreeBSD, too, and I 
have to discover MTU myself.

Is this a known bug ?

By the way, are there any plans to support FreeBSD MTU discovery ?

Thanks !
Oleg Moskalenko






Re: Failing to verify the certificate of one specific site

2011-10-19 Thread Lucas Clemente Vella
2011/10/9 Lucas Clemente Vella lve...@gmail.com:
 First of all, I am not a direct user of the OpenSSL library, but I am
 using it via Python 2.7 built-in module ssl, which in turn uses
 OpenSSL. Since my problem is SSL specific, I thought people here would
 be more apt to help me.

Now I wrote the C code using directly OpenSSL, and I get the same problem:

#include stdio.h
#include openssl/bio.h
#include openssl/ssl.h
#include openssl/err.h

int main()
{
  long ret;
  BIO * bio;
  SSL_CTX * ctx;
  SSL * ssl;
  X509 * cert;

  SSL_library_init();
  SSL_load_error_strings();
  ERR_load_BIO_strings();

  ctx = SSL_CTX_new(TLSv1_client_method());
  SSL_CTX_load_verify_locations(ctx, DigiCertHighAssuranceEVRootCA.crt, NULL);

  bio = BIO_new_ssl_connect(ctx);
  BIO_get_ssl(bio, ssl);
  SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);

  BIO_set_conn_hostname(bio, graph.facebook.com:443);
  BIO_do_connect(bio);

  cert = SSL_get_peer_certificate(ssl);
  ret = SSL_get_verify_result(ssl);

  printf(Cert: %s\nRet %ld\n, cert-name, ret);

  X509_free(cert);
  BIO_free_all(bio);
  SSL_CTX_free(ctx);
}

By running it, I get:
$ ssl_test
Cert: /C=US/ST=California/L=Palo Alto/O=Facebook, Inc./CN=*.facebook.com
Ret 20

which Ret 20 means, according to 'man verify',
20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY

where I would expect:
0 X509_V_OK

Then I found this directory in my system, /etc/ssl/certs, containing
my installed CA roots, which I provided to OpenSSL, instead of the
certificate file:
SSL_CTX_load_verify_locations(ctx, NULL, /etc/ssl/certs);

By running again, I get Ret 0, meaning X509_V_OK and the host was verified.

It seems to me that there is one certificate installed in
/etc/ssl/certs, which is different from the on I was providing, that
is being used to verify the host. If it is so, how can I know what
certificate is being used? And why Firefox and Chrome both use the
former certificate I provided, while OpenSSL is unable to use it for
the same host?

-- 
Lucas Clemente Vella
lve...@gmail.com
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org