Skip to content

Commit cd1b87b

Browse files
committed
Remove useless check for valid certificate
If certificate check fails, SSL_Connect will fail, thus the removed code will not run. It would only runs when successful. That function is meant to check the error code when there is a certificate validation issue. SSL_get_verify_result is being used incorrectly here; it is intended to get the validation error reason when SSL_Connect fails, and that failure is due to an invalid certificate.
1 parent 0b7db36 commit cd1b87b

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

platform/posix/transport/src/openssl_posix.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static OpensslStatus_t tlsHandshake( const ServerInfo_t * pServerInfo,
241241
const OpensslCredentials_t * pOpensslCredentials )
242242
{
243243
OpensslStatus_t returnStatus = OPENSSL_SUCCESS;
244-
int32_t sslStatus = -1, verifyPeerCertStatus = X509_V_OK;
244+
int32_t sslStatus = -1;
245245

246246
/* Validate the hostname against the server's certificate. */
247247
sslStatus = SSL_set1_host( pOpensslParams->pSsl, pServerInfo->pHostName );
@@ -282,19 +282,6 @@ static OpensslStatus_t tlsHandshake( const ServerInfo_t * pServerInfo,
282282
}
283283
}
284284

285-
/* Verify X509 certificate from peer. */
286-
if( returnStatus == OPENSSL_SUCCESS )
287-
{
288-
verifyPeerCertStatus = ( int32_t ) SSL_get_verify_result( pOpensslParams->pSsl );
289-
290-
if( verifyPeerCertStatus != X509_V_OK )
291-
{
292-
LogError( ( "SSL_get_verify_result failed to verify X509 "
293-
"certificate from peer." ) );
294-
returnStatus = OPENSSL_HANDSHAKE_FAILED;
295-
}
296-
}
297-
298285
return returnStatus;
299286
}
300287

0 commit comments

Comments
 (0)