Skip Menu | | Logout
Logged in as guest
RT for openssl.org
 
 
#1513: Bug : SSL_CTX_use_certificate_chain_file fails due to earlier errors
X  Ticket metadata  
X  The Basics  
Id: 1513
Status: resolved
Left: 0 min
Priority: 0/0
Queue: OpenSSL-Bugs

X  Custom Fields  
Milestone:
  • (no value)
Subsystem:
  • (no value)
Severity:
  • (no value)
Broken in:
  • (no value)

X  People  
Owner: jaenicke <lutz@lutz-jaenicke.de>
Requestors: mle+openssl@mega-nerd.com
Cc:
AdminCc:

X  Dates  
Created: Thu Mar 22 11:09:50 2007
Starts: Not set
Started: Fri May 23 12:32:11 2008
Last Contact: Fri May 23 12:38:09 2008
Due: Not set
Closed: Fri May 23 12:38:09 2008
Updated: Fri May 23 12:39:14 2008 by jaenicke

X  Links  
Depends on:
Depended on by:
Parents:
Children:
Refers to:
Referred to by:

X  More about Erik de Castro Lopo  
Comments about this user:
No comment entered about this user
This user's 10 highest priority tickets:
Groups this user belongs to:
  • Everyone
  • Unprivileged

X  History Display mode:[Brief headers] [Full headers]
#     Thu Mar 22 11:09:51 2007  mle+openssl@mega-nerd.com - Ticket created    
Subject: Bug : SSL_CTX_use_certificate_chain_file fails due to earlier errors
Date: Wed, 21 Mar 2007 10:06:47 +1100
To: openssl-dev@openssl.org
From: Erik de Castro Lopo <mle+openssl@mega-nerd.com>
Download (untitled)
text/plain 1.9k
Hi all,

In the test suite for some C++ classes I'm writing, I deliberately
invoke errors so I can test the error handling of my code. Doing
this means that I have also turned up an error in the OpenSSL
error handling.

The problem I was seeing was that I would invoke an error and
then in the next test, call SSL_CTX_use_certificate_chain_file
which would fail.

Tracing this into the OpenSSL code I found that the call to
SSL_CTX_use_certificate expects that some global error state
is zero before it is called. If it isn't zero,
SSL_CTX_use_certificate_chain_file will report an error even
though the read error occurred earlier and there was not valid
reason for SSL_CTX_use_certificate_chain_file to fail.

I fixed this issue with the following patch. The patch is probably
not the best way to fix this error, but solved my immediate problem.

If the OpenSSL devs can come up with a better fix I'll be happy
to go with that.

Cheers,
Erik


diff -ru openssl-0.9.8e/ssl/ssl_rsa.c openssl-0.9.8e-hacked/ssl/ssl_rsa.c
--- openssl-0.9.8e/ssl/ssl_rsa.c 2005-04-09 08:52:41.000000000 +1000
+++ openssl-0.9.8e-hacked/ssl/ssl_rsa.c 2007-03-19 09:03:15.000000000 +1100
@@ -728,6 +728,9 @@
goto end;
}

+ /* Must clear error before calling SSL_CTX_use_certificate. */
+ ERR_clear_error();
+
ret=SSL_CTX_use_certificate(ctx,x);
if (ERR_peek_error() != 0)
ret = 0; /* Key/certificate mismatch doesn't imply ret==0 ... */


--
+-----------------------------------------------------------+
Erik de Castro Lopo
+-----------------------------------------------------------+
"Men who use terrorism as a means to power, rule by terror
once they are in power."
-- Helen Macinnes
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List openssl-dev@openssl.org
Automated List Manager majordomo@openssl.org
#     Fri May 23 12:32:10 2008  jaenicke - Taken    
#     Fri May 23 12:32:11 2008  jaenicke - Status changed from 'new' to 'open'    
#     Fri May 23 12:38:08 2008  jaenicke - Correspondence added    
Download (untitled)
text/plain 83b
Respective patch applied, thanks.
The fix will be in 0.9.8h.

Best regards,
Lutz
#     Fri May 23 12:38:09 2008  jaenicke - Status changed from 'open' to 'resolved'    
#     Fri May 23 12:39:14 2008  jaenicke - Reference by ticket #1417 added    
»|« RT 3.4.5 Copyright 1996-2005 Best Practical Solutions, LLC.
Time to display: 0.590787