Skip to content

Commit 37c0613

Browse files
committed
Cleanup unused parameters
1 parent 397cec6 commit 37c0613

File tree

2 files changed

+20
-46
lines changed

2 files changed

+20
-46
lines changed

platform/posix/transport/include/openssl_posix.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,9 @@ typedef struct OpensslCredentials
135135
*
136136
* @note These strings must be NULL-terminated because the OpenSSL API requires them to be.
137137
*/
138-
const char * pRootCaPath; /**< @brief Filepath string to the trusted server root CA. */
139-
const char * pClientCertPath; /**< @brief Filepath string to the client certificate. */
140-
const char * pPrivateKeyPath; /**< @brief Filepath string or PKCS11 URI to the client certificate's private key. */
141-
142-
/**
143-
* @brief Configuration options when using a pkcs11 module.
144-
*
145-
* @note These strings must be NULL-terminated because the OpenSSL API requires them to be.
146-
*/
147-
const char * pP11ModulePath; /**< @brief Filepath string to the desired pkcs11 module. */
148-
const char * pP11ModulePin; /**< @brief String containing the pin (if required) for the referenced pkcs11 module */
138+
const char * pRootCaPath; /**< @brief File path or PKCS#11 URI to the trusted server root CA certificate. */
139+
const char * pClientCertPath; /**< @brief File path or PKCS#11 URI to the tls client certificate. */
140+
const char * pPrivateKeyPath; /**< @brief File path or PKCS#11 URI to the tls client private key. */
149141
} OpensslCredentials_t;
150142

151143
/**

platform/posix/transport/src/openssl_posix.c

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ struct NetworkContext
9090
*/
9191
static int32_t opensslError( void );
9292

93+
/**
94+
* @brief Load a certificate with the given PKCS#11 URI and return the resulting openssl X509 object.
95+
*
96+
* @param[out] ppX509Cert Location to store a pointer to the created X509 certificate object.
97+
* @param[in] pEngine Pointer to the pre-initialized openssl PKCS11 engine.
98+
* @param[in] pCertURI PKCS#11 URI for the desired certificate.
99+
*
100+
* @return 1 on success; -1, 0 on failure.
101+
*/
102+
static int32_t loadCertificateFromPkcs11( X509 ** ppX509Cert,
103+
ENGINE * pEngine,
104+
const char * pCertURI );
105+
93106
/**
94107
* @brief Add X509 certificate from a file to the trusted list of root certificates.
95108
*
@@ -168,17 +181,10 @@ static int32_t setPrivateKeyFromPkcs11( SSL_CTX * pSslContext,
168181
* @brief Initialize the openssl pkcs11 engine.
169182
*
170183
* @param[out] ppEngine Pointer to write the resulting ENGINE object pointer to.
171-
* @param[in] pP11ModulePath String containing the path to the PKCS11 module.
172-
* @param[in] pP11ModulePin String containing the pin code (if needed).
173-
*
174-
* The pP11ModulePath and pP11ModulePin parameters may be NULL if spcified
175-
* in the relevant URI or openssl configuration file.
176184
*
177185
* @return 1 on success; 0 on failure.
178186
*/
179-
static int32_t initializePkcs11Engine( ENGINE ** ppEngine,
180-
const char * pP11ModulePath,
181-
const char * pP11ModulePin );
187+
static int32_t initializePkcs11Engine( ENGINE ** ppEngine );
182188

183189
/**
184190
* @brief Passes TLS credentials to the OpenSSL library.
@@ -690,9 +696,7 @@ static int32_t opensslError( void )
690696
}
691697

692698
/*-----------------------------------------------------------*/
693-
static int32_t initializePkcs11Engine( ENGINE ** ppEngine,
694-
const char * pP11ModulePath,
695-
const char * pP11ModulePin )
699+
static int32_t initializePkcs11Engine( ENGINE ** ppEngine )
696700
{
697701
int32_t sslStatus = 1;
698702
ENGINE * pEngine = NULL;
@@ -713,23 +717,13 @@ static int32_t initializePkcs11Engine( ENGINE ** ppEngine,
713717
/* Increase log level if necessary */
714718
#if LIBRARY_LOG_LEVEL >= LOG_INFO
715719
if( ( sslStatus == 1 ) &&
716-
( ENGINE_ctrl_cmd_string(engine, "VERBOSE", NULL, 0 ) != 1 ) )
720+
( ENGINE_ctrl_cmd_string(pEngine, "VERBOSE", NULL, 0 ) != 1 ) )
717721
{
718722
LogError( ( "Failed to increment the pkcs11 engine verbosity level." ) );
719723
sslStatus = opensslError();
720724
}
721725
#endif
722726

723-
/* Set module path if specified */
724-
if( sslStatus == 1 && pP11ModulePath != NULL )
725-
{
726-
if( ENGINE_ctrl_cmd_string( pEngine, "MODULE_PATH", pP11ModulePath, 0 ) != 1 )
727-
{
728-
LogError( ( "Failed to set the pkcs11 module path: %s.", pP11ModulePath ) );
729-
sslStatus = opensslError();
730-
}
731-
}
732-
733727
if( sslStatus == 1 )
734728
{
735729
/* Initialize the pkcs11 engine and acquire a functional reference to it */
@@ -740,16 +734,6 @@ static int32_t initializePkcs11Engine( ENGINE ** ppEngine,
740734
}
741735
}
742736

743-
/* Unlock with pin code if specified */
744-
if( sslStatus == 1 && pP11ModulePin != NULL )
745-
{
746-
if( ENGINE_ctrl_cmd_string( pEngine, "PIN", pP11ModulePin, 0 ) != 1 )
747-
{
748-
LogError( ( "Failed to unlock the pkcs11 module with the given pin code." ) );
749-
sslStatus = opensslError();
750-
}
751-
}
752-
753737
if( sslStatus == 1 )
754738
{
755739
*ppEngine = pEngine;
@@ -799,9 +783,7 @@ static int32_t setCredentials( SSL_CTX * pSslContext,
799783

800784
if( pkeyFromP11 == true || certFromP11 == true || rootCaFromP11 == true )
801785
{
802-
sslStatus = initializePkcs11Engine( &pEngine,
803-
pOpensslCredentials->pP11ModulePath,
804-
pOpensslCredentials->pP11ModulePin );
786+
sslStatus = initializePkcs11Engine( &pEngine );
805787
}
806788
}
807789

0 commit comments

Comments
 (0)