#210757 openssl: s_client -verify should (optionally) exit with error on verification failure

Package:
openssl
Source:
openssl
Description:
Secure Sockets Layer toolkit - cryptographic utility
Submitter:
Hein Roehrig
Date:
2014-10-03 16:09:11 UTC
Severity:
wishlist
#210757#5
Date:
2003-09-13 13:25:44 UTC
From:
To:
The BUG section in the s_client manpage says:

       The -verify option should really exit if the server verification fails.

Indeed, this would be very desirable as s_client is actually used in
"production" by gnus to talk SSL to IMAP servers...

This shouldn't be too hard to implement, unless I am not getting the
big picture. I could offer a patch if desired.

TIA,
Hein

#210757#10
Date:
2003-09-13 15:58:12 UTC
From:
To:
tags 210757 - security
thanks

Since this is documented behaviour, and s_client is only meant as a
diagnostic tool, I don't consider this bug to be security-related.

#210757#17
Date:
2003-10-07 10:38:20 UTC
From:
To:
Hi Hein,

Hein Roehrig schrieb:

Please check if the problem persists in version 0.9.7c. If not, please
supply a patch and I try to submit it to upstream.

Christoph

#210757#22
Date:
2011-04-17 10:16:15 UTC
From:
To:
Hi,

Not sure but this problem might have been fixed in OpenSSL 1.0.0.

The CHANGES file of OpenSSL reads:

  *) Overhaul of by_dir code. Add support for dynamic loading of CRLs so
     new CRLs added to a directory can be used. New command line option
     -verify_return_error to s_client and s_server. This causes real errors
     to be returned by the verify callback instead of carrying on no matter
     what. This reflects the way a "real world" verify callback would behave.
     [Steve Henson]

After openssl was updated from 0.9.8 to 1.0.0d on Debian Testing a
connection to a server with -verifiy 0 fails:

dmaus@x60s ~/downloads/openssl-1.0.0d % openssl s_client -host imap.gmail.com -port 993 -verify 0
verify depth is 0
CONNECTED(00000004)
depth=1 C = US, O = Google Inc, CN = Google Internet Authority
verify error:num=20:unable to get local issuer certificate
verify return:0
3075614872:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed:s3_clnt.c:1059:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 1659 bytes and written 7 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : SSLv3
    Cipher    : 0000
    Session-ID: 2FA72DF43480C0FA6915471620298C1B1F669D3B4542A985EDF9137C9FF95234
    Session-ID-ctx:
    Master-Key:
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    Start Time: 1303035213
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
---
1 dmaus@x60s ~/downloads/openssl-1.0.0d %

The -verify_return_error argument is not documented in the man-page
(or the help output) and I haven't found a way to turn it off.

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

#210757#27
Date:
2014-10-03 16:07:43 UTC
From:
To:
This is working for me in Wheezy, just need to add the extra parameter.
Something like this achieves the requested behavior:

openssl s_client -verify 3 -verify_return_error -CApath /etc/ssl/certs/
-starttls imap -connect mail.example.com:143

This is also documented in the man and in `openssl s_client -h`. So I
thinks this bug should be closed.