Re: trust chain building for X509_verify_cert

2012-06-06 Thread Vladimir Belov


His code WORKS fine with OpenSSL library initialization. I checked.
The verification failed because OpenSSL couldn’t find digest algorithm.
Special error checking isn't needed now, the reason is the absence of 
OpenSSL_add_all_algorithms function or similar.

---
From: Dave Thompson
Sent: Thursday, June 07, 2012 5:43 AM
To: openssl-users@openssl.org
Cc: 'Alexander Kirschner'
Subject: RE: trust chain building for X509_verify_cert

From: owner-openssl-us...@openssl.org On Behalf Of Arthur Spitzer
Sent: Tuesday, 05 June, 2012 04:48



I need to verify a X.509 certificate against a self-signed X.509 CA,
both certificates are in PEM-format. Doing this on the command line
works so far: 
Right now I am working on a small piece of code that is supposed to
do the same from C++ using the X509_verify_cert function.



The problem is: The verification always fails with error code 7

("signature invalid"). I already tried three different attempts

(documented in the attached cpp file) to build the trust chain,
with the same result.


verify error 7 isn't a chain building problem, it's an error
verifying the signature (on the cert, against the parent).

http://www.openssl.org/support/faq.html#PROG6 tells you to
do ERR_print_errors_fp (or equivalent) which says 0D0C50A1, and
http://www.openssl.org/support/faq.html#PROG7 tells you to
ERR_load_crypto_strings (or equivalent, e.g. for SSL apps use
SSL_load_error_strings) which says ...:unknown message digest algorithm
and http://www.openssl.org/support/faq.html#PROG8
tells you OpenSSL_add_all_algorithms (or equivalent).


__
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: trust chain building for X509_verify_cert

2012-06-06 Thread Dave Thompson
>From: owner-openssl-us...@openssl.org On Behalf Of Arthur Spitzer
>Sent: Tuesday, 05 June, 2012 04:48

>I need to verify a X.509 certificate against a self-signed X.509 CA, 
>both certificates are in PEM-format. Doing this on the command line 
>works so far: 
>Right now I am working on a small piece of code that is supposed to 
>do the same from C++ using the X509_verify_cert function.

>The problem is: The verification always fails with error code 7 
("signature invalid"). I already tried three different attempts 
>(documented in the attached cpp file) to build the trust chain, 
>with the same result.

verify error 7 isn't a chain building problem, it's an error 
verifying the signature (on the cert, against the parent).

http://www.openssl.org/support/faq.html#PROG6 tells you to 
do ERR_print_errors_fp (or equivalent) which says 0D0C50A1, and 
http://www.openssl.org/support/faq.html#PROG7 tells you to 
ERR_load_crypto_strings (or equivalent, e.g. for SSL apps use 
SSL_load_error_strings) which says ...:unknown message digest algorithm 
and http://www.openssl.org/support/faq.html#PROG8
tells you OpenSSL_add_all_algorithms (or equivalent).


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


Re: trust chain building for X509_verify_cert

2012-06-06 Thread Bruce Stephens
Arthur Spitzer 
writes:

[...]

> The problem is: The verification always fails with error code 7
> (“signature invalid”). I already tried three different attempts
> (documented in the attached cpp file) to build the trust chain, with
> the same result.
>
> The relevant source code (certificates as char arrays included in the
> cpp) and both certificates are attached. I would be very grateful if
> you could give me a hint. Right now I am a little lost.

You don't seem to be calling OpenSSL_add_all_algorithms() (or adding any
algorithms).


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


Re: trust chain building for X509_verify_cert

2012-06-06 Thread Vladimir Belov


Hi, Arthur.

The verification always fails because OpenSSL can’t find digest algorithm. You(as I just now) forgot about OpenSSL 
initialization. You must add at the beginning of the main function next code:


//SSLeay library init (libcrypto)
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();


There are another variants of initialization(if will be necessary):
//SSL library init(libssl)
ERR_load_SSL_strings();
SSL_library_init();

//OpenSSL library init (both libcrypto and libssl)
SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();


--
From: Arthur Spitzer
Sent: Tuesday, June 05, 2012 12:48 PM
To: openssl-users@openssl.org
Cc: Alexander Kirschner
Subject: trust chain building for X509_verify_cert

Hi,

I need to verify a X.509 certificate against a self-signed X.509 CA, both certificates are in PEM-format. Doing this on 
the command line works so far:


openssl verify -CAfile caCertificate.pem certificate.pem
certificate.pem: OK

The version of OpenSSL is: 1.0.0j-fips 10 May 2012.

Right now I am working on a small piece of code that is supposed to do the same from C++ using the X509_verify_cert 
function.


The problem is: The verification always fails with error code 7 (“signature invalid”). I already tried three different 
attempts (documented in the attached cpp file) to build the trust chain, with the same result.


The relevant source code (certificates as char arrays included in the cpp) and both certificates are attached. I would 
be very grateful if you could give me a hint. Right now I am a little lost.


Thanks in advance & Best regards,

Arthur


Dipl.-Math. Arthur Spitzer, Software Architect
Phone: +49.89.45 23 47 - 260


jambit Software Development & Management GmbH
Erika-Mann-Str. 63, 80636 München
Phone: +49.89.45 23 47-0 Fax: +49.89.45 23 47-70

http://www.jambit.com where innovation works

Geschäftsführer: Peter F. Fellinger, Markus Hartinger
Sitz: München; Registergericht: München, HRB 129139

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


trust chain building for X509_verify_cert

2012-06-05 Thread Arthur Spitzer
Hi,

I need to verify a X.509 certificate against a self-signed X.509 CA, both 
certificates are in PEM-format. Doing this on the command line works so far:
openssl verify -CAfile caCertificate.pem certificate.pem
certificate.pem: OK
The version of OpenSSL is: 1.0.0j-fips 10 May 2012.

Right now I am working on a small piece of code that is supposed to do the same 
from C++ using the X509_verify_cert function.

The problem is: The verification always fails with error code 7 (“signature 
invalid”). I already tried three different attempts (documented in the attached 
cpp file) to build the trust chain, with the same result.

The relevant source code (certificates as char arrays included in the cpp) and 
both certificates are attached. I would be very grateful if you could give me a 
hint. Right now I am a little lost.

Thanks in advance & Best regards,

Arthur


Dipl.-Math. Arthur Spitzer, Software Architect
Phone: +49.89.45 23 47 - 260


jambit Software Development & Management GmbH
Erika-Mann-Str. 63, 80636 München
Phone: +49.89.45 23 47-0 Fax: +49.89.45 23 47-70

http://www.jambit.com where innovation works

Geschäftsführer: Peter F. Fellinger, Markus Hartinger
Sitz: München; Registergericht: München, HRB 129139

#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 


#define nullptr 0

const char* certificateAsPem = "-BEGIN CERTIFICATE-\n"
"MIIGyDCCBLCgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBnTELMAkGA1UEBhMCREUx\n"
"EzARBgNVBAgMClNvbWUtU3RhdGUxEjAQBgNVBAcMCVNvbWUtQ2l0eTEVMBMGA1UE\n"
"CgwMU29tZSBDb21wYW55MRgwFgYDVQQLDA9Tb21lT2ZmaWNlIFVuaXQxEzARBgNV\n"
"BAMMClRydXN0IFJvb3QxHzAdBgkqhkiG9w0BCQEWEG1haWxAZXhhbXBsZS5jb20w\n"
"HhcNMTIwNjA0MTUxMTQ2WhcNMzIwNjA0MTUxMTQ2WjCBpjELMAkGA1UEBhMCREUx\n"
"EzARBgNVBAgMClNvbWUtU3RhdGUxEjAQBgNVBAcMCVNvbWUtQ2l0eTEVMBMGA1UE\n"
"CgwMU29tZSBDb21wYW55MRgwFgYDVQQLDA9Tb21lT2ZmaWNlIFVuaXQxHDAaBgNV\n"
"BAMME0RldmljZSBNYW51ZmFjdHVyZXIxHzAdBgkqhkiG9w0BCQEWEG1haWxAZXhh\n"
"bXBsZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/s2Hnww8o\n"
"wtqvj5zrU9R5vmERsOrwMblHBwgD8PXOnAxSVTFYX13hn2NLLksnFdjwK3nsokj/\n"
"Y8Mg1hVX/iHy9gzt5wBnfu5EqUAY8d+8Du4leHM0AT3Q5RFkLlKukEM8/Ct2HnJa\n"
"P8KKeI80oy/xEZsE7KkLWb6I9BLnIvh8eHggylPJdbAamnxMUQAwddSIvSbZ+uTx\n"
"FCWgr/S0oNxByfc5BEKQF5O+GWti9FzgkpOoKG8LtMhPUL0srkY/5gJNJLFZa799\n"
"murYwHbqw0/m8CE58/sssVSu9DyiuX1SCf4tI69+tzNqs5OJCjQw5yM6XsqikCAu\n"
"OUdpJ6UdVev+BwNYkZxaohVkFF0jNIJj8PFJS3b7F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