cryptImportCert fails due to base64decode problem
"Ludo Brands" <[email protected]>
| Newsgroups | gmane.comp.encryption.cryptlib |
|---|---|
| Message-ID | <000401cbd5c1$42eace40$6c02a8c0@Ludo10> |
Hi,
when importing a bunch of PEM certificates I found out that certificates
(base64, surrounded with -----BEGIN CERTIFICATE----- -----END
CERTIFICATE-----) would fail with a CRYPT_ERROR_BADDATA when the last base64
character was not "=" (ie. no padding). This is on windows.
Debugging the problem I found out that line 612 in base64.c (3.4.0) was the
problem.
if( c0 == BEOF )
{
/* No more input, we're done */
return( 0 ); // PROBLEM HERE
}
Returning 0 causes function base64decode to continue decoding chunks (when
last line is shorter than lineSize) until it breaks on the '-' characters in
"-----END CERTIFICATE-----".
When modifying to
if( c0 == BEOF )
{
/* No more input, we're done */
return( OK_SPECIAL );
}
this problem is solved.
The list of certificates I was trying to import can be found on
http://curl.haxx.se/ca/cacert.pem. When you cut the first cert (GTE
CyberTrust Global Root) and paste it in for example cert2.asc in the
test/certs directory, the test32 suite will break on that certificate.
Best regards, Ludo
_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.