Remove unreachable code from SSL_use_certificate_file() as in SSL_CTX_use_certificate...
authoratishkov <a.tishkov@aladdin.ru>
Fri, 7 Jul 2023 13:00:38 +0000 (16:00 +0300)
committerPauli <pauli@openssl.org>
Sun, 16 Jul 2023 22:52:30 +0000 (08:52 +1000)
CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/21394)

ssl/ssl_rsa.c

index 3d4ad85a62b41a4a989444909974a7370d93837d..1df087abd1a278fdc0ec3b7e8f73594c6cd72c83 100644 (file)
@@ -68,10 +68,6 @@ int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
         goto end;
     }
 
-    if (type != SSL_FILETYPE_ASN1 && type != SSL_FILETYPE_PEM) {
-        ERR_raise(ERR_LIB_SSL, SSL_R_BAD_SSL_FILETYPE);
-        goto end;
-    }
     x = X509_new_ex(ssl->ctx->libctx, ssl->ctx->propq);
     if (x == NULL) {
         ERR_raise(ERR_LIB_SSL, ERR_R_ASN1_LIB);
@@ -314,10 +310,7 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
         ERR_raise(ERR_LIB_SSL, ERR_R_SYS_LIB);
         goto end;
     }
-    if (type != SSL_FILETYPE_ASN1 && type != SSL_FILETYPE_PEM) {
-        ERR_raise(ERR_LIB_SSL, SSL_R_BAD_SSL_FILETYPE);
-        goto end;
-    }
+
     x = X509_new_ex(ctx->libctx, ctx->propq);
     if (x == NULL) {
         ERR_raise(ERR_LIB_SSL, ERR_R_ASN1_LIB);
@@ -330,6 +323,9 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
         j = ERR_R_PEM_LIB;
         cert = PEM_read_bio_X509(in, &x, ctx->default_passwd_callback,
                                  ctx->default_passwd_callback_userdata);
+    } else {
+        ERR_raise(ERR_LIB_SSL, SSL_R_BAD_SSL_FILETYPE);
+        goto end;
     }
     if (cert == NULL) {
         ERR_raise(ERR_LIB_SSL, j);