Skip to content

Commit dff1232

Browse files
committed
Allow disabling of server cert hostname check
1 parent cd1b87b commit dff1232

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

platform/posix/transport/include/openssl_posix.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ typedef struct OpensslCredentials
118118
*/
119119
const char * sniHostName;
120120

121+
/**
122+
* @brief If non-zero, don't compare hostname to server certificate subject.
123+
*/
124+
uint8_t disableHostnameCheck;
125+
121126
/**
122127
* @brief Set the value for the TLS max fragment length (TLS MFLN)
123128
*

platform/posix/transport/src/openssl_posix.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,15 @@ static OpensslStatus_t tlsHandshake( const ServerInfo_t * pServerInfo,
244244
int32_t sslStatus = -1;
245245

246246
/* Validate the hostname against the server's certificate. */
247-
sslStatus = SSL_set1_host( pOpensslParams->pSsl, pServerInfo->pHostName );
248-
249-
if( sslStatus != 1 )
247+
if( pOpensslCredentials->disableHostnameCheck == 0U )
250248
{
251-
LogError( ( "SSL_set1_host failed to set the hostname to validate." ) );
252-
returnStatus = OPENSSL_API_ERROR;
249+
sslStatus = SSL_set1_host( pOpensslParams->pSsl, pServerInfo->pHostName );
250+
251+
if( sslStatus != 1 )
252+
{
253+
LogError( ( "SSL_set1_host failed to set the hostname to validate." ) );
254+
returnStatus = OPENSSL_API_ERROR;
255+
}
253256
}
254257

255258
/* Enable SSL peer verification. */

0 commit comments

Comments
 (0)