Allow checking of self-signed certifictes if a flag is set.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 26 Jun 2009 11:28:52 +0000 (11:28 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 26 Jun 2009 11:28:52 +0000 (11:28 +0000)
CHANGES
apps/apps.c
apps/x509.c
crypto/x509/x509_vfy.c
crypto/x509/x509_vfy.h
doc/apps/cms.pod
doc/apps/s_client.pod
doc/apps/smime.pod
doc/apps/verify.pod

diff --git a/CHANGES b/CHANGES
index d74262e1bba975aed2bc14130852d21919995608..b886dbfeecfa8aa856837781d3ef366510dd9d46 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 
  Changes between 0.9.8k and 0.9.8l  [xx XXX xxxx]
 
-  *) Don't check self signed certificate signatures in X509_verify_cert():
-     it just wastes time without adding any security. As a useful side effect
-     self signed root CAs with non-FIPS digests are now usable in FIPS mode.
+  *) Don't check self signed certificate signatures in X509_verify_cert()
+     by default (a flag can override this): it just wastes time without
+     adding any security. As a useful side effect self signed root CAs
+     with non-FIPS digests are now usable in FIPS mode.
      [Steve Henson]
 
   *) In dtls1_process_out_of_seq_message() the check if the current message
index 47413f58273f9ce1c1f6f46254fef109c396d5e6..08ce00822ed50e37046abc258df5afe93fa227ef 100644 (file)
@@ -2256,6 +2256,8 @@ int args_verify(char ***pargs, int *pargc,
                flags |= X509_V_FLAG_USE_DELTAS;
        else if (!strcmp(arg, "-policy_print"))
                flags |= X509_V_FLAG_NOTIFY_POLICY;
+       else if (!strcmp(arg, "-check_ss_sig"))
+               flags |= X509_V_FLAG_CHECK_SS_SIGNATURE;
        else
                return 0;
 
index 6e49377f0d5c6d81382564054e78b55489ea9d03..5e81ee8c3f41cadb307cc5be4b22f2d32b92ea17 100644 (file)
@@ -1130,6 +1130,7 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
        /* NOTE: this certificate can/should be self signed, unless it was
         * a certificate request in which case it is not. */
        X509_STORE_CTX_set_cert(&xsc,x);
+       X509_STORE_CTX_set_flags(&xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
        if (!reqfile && X509_verify_cert(&xsc) <= 0)
                goto end;
 
index dd4065b0ceb6ac545e7b1a65e84d736b5709b9bc..200a9cc0b6bab27359e1aeb99c58d021a3d8cefa 100644 (file)
@@ -1610,10 +1610,11 @@ static int internal_verify(X509_STORE_CTX *ctx)
                {
                ctx->error_depth=n;
 
-               /* Skip signature check for self signed certificates. It
-                * doesn't add any security and just wastes time.
+               /* Skip signature check for self signed certificates unless
+                * explicitly asked for. It doesn't add any security and
+                * just wastes time.
                 */
-               if (!xs->valid && xs != xi)
+               if (!xs->valid && (xs != xi || (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE)))
                        {
                        if ((pkey=X509_get_pubkey(xi)) == NULL)
                                {
index 0df76db84920bf27cc808281fa07c0c8bad6ab39..4e73806adc3c324b1556fe01f3368c9ee9cdb9b3 100644 (file)
@@ -387,6 +387,9 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
 #define X509_V_FLAG_EXTENDED_CRL_SUPPORT       0x1000
 /* Delta CRL support */
 #define X509_V_FLAG_USE_DELTAS                 0x2000
+/* Check selfsigned CA signature */
+#define X509_V_FLAG_CHECK_SS_SIGNATURE         0x4000
+
 
 #define X509_VP_FLAG_DEFAULT                   0x1
 #define X509_VP_FLAG_OVERWRITE                 0x2
index 520279eeabcdf83c7a45d4f5bc3366a67064bd91..d62961a02379fd12a65988f172a3b428a8d03536 100644 (file)
@@ -401,7 +401,7 @@ portion of a message so they may be included manually. If signing
 then many S/MIME mail clients check the signers certificate's email
 address matches that specified in the From: address.
 
-=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy>
+=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig>
 
 Set various certificate chain valiadition option. See the
 L<B<verify>|verify(1)> manual page for details.
index f61b80c720a2c8a9c835b7a0c863aeb86a5543ce..4ebf7b5854740760d13cd289acc4755c24d96d32 100644 (file)
@@ -101,7 +101,7 @@ also used when building the client certificate chain.
 A file containing trusted certificates to use during server authentication
 and to use when attempting to build the client certificate chain.
 
-=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy>
+=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig>
 
 Set various certificate chain valiadition option. See the
 L<B<verify>|verify(1)> manual page for details.
index 97cc0dc789edaf7171ffa952511b99b91914e5f6..e0258b5648600001ff8b57ba0500b338943c6f03 100644 (file)
@@ -259,7 +259,7 @@ portion of a message so they may be included manually. If signing
 then many S/MIME mail clients check the signers certificate's email
 address matches that specified in the From: address.
 
-=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy>
+=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig>
 
 Set various options of certificate chain verification. See
 L<B<verify>|verify(1)> manual page for details.
index dad3d17c83cd6ce82c91ac96935bd262e998add4..bd399dc7723dc43363c777df162bb863b31b989d 100644 (file)
@@ -135,6 +135,11 @@ signing keys.
 
 Enable support for delta CRLs.
 
+=item B<-check_ss_sig>
+
+Verify the signature on the self-signed root CA. This is disabled by default
+because it doesn't add any security.
+
 =item B<->
 
 marks the last option. All arguments following this are assumed to be