From: atishkov Date: Fri, 7 Jul 2023 13:00:38 +0000 (+0300) Subject: Remove unreachable code from SSL_use_certificate_file() as in SSL_CTX_use_certificate... X-Git-Tag: openssl-3.2.0-alpha1~408 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33ef5fc2c2bf0b0587bfcba28f61329abd83be70;p=thirdparty%2Fopenssl.git Remove unreachable code from SSL_use_certificate_file() as in SSL_CTX_use_certificate_file() CLA: trivial Reviewed-by: Tomas Mraz Reviewed-by: David von Oheimb (Merged from https://github.com/openssl/openssl/pull/21394) --- diff --git a/ssl/ssl_rsa.c b/ssl/ssl_rsa.c index 3d4ad85a62b..1df087abd1a 100644 --- a/ssl/ssl_rsa.c +++ b/ssl/ssl_rsa.c @@ -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);