Skip to content

Commit 8b26fd9

Browse files
authored
Additional modifications to the final submission (#149)
1 parent f72bc68 commit 8b26fd9

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

trantor/net/TcpClient.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,15 @@ void TcpClient::removeConnection(const TcpConnectionPtr &conn)
202202
}
203203
}
204204

205-
void TcpClient::enableSSL(bool useOldTLS,
206-
bool validateCert,
207-
std::string hostname)
205+
void TcpClient::enableSSL(
206+
bool useOldTLS,
207+
bool validateCert,
208+
std::string hostname,
209+
const std::vector<std::pair<std::string, std::string>> &sslConfCmds)
208210
{
209211
#ifdef USE_OPENSSL
210212
/* Create a new OpenSSL context */
211-
sslCtxPtr_ = newSSLContext(useOldTLS, validateCert, {});
213+
sslCtxPtr_ = newSSLContext(useOldTLS, validateCert, sslConfCmds);
212214
validateCert_ = validateCert;
213215
if (!hostname.empty())
214216
{

trantor/net/TcpClient.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,20 @@ class TRANTOR_EXPORT TcpClient : NonCopyable
193193
* @brief Enable SSL encryption.
194194
* @param useOldTLS If true, the TLS 1.0 and 1.1 are supported by the
195195
* client.
196-
* @param hostname The server hostname for SNI. If it is empty, the SNI is
197-
* not used.
198196
* @param validateCert If true, we try to validate if the peer's SSL cert
199197
* is valid.
198+
* @param hostname The server hostname for SNI. If it is empty, the SNI is
199+
* not used.
200+
* @param sslConfCmds The commands used to call the SSL_CONF_cmd function in
201+
* OpenSSL.
200202
* @note It's well known that TLS 1.0 and 1.1 are not considered secure in
201203
* 2020. And it's a good practice to only use TLS 1.2 and above.
202204
*/
203205
void enableSSL(bool useOldTLS = false,
204206
bool validateCert = true,
205-
std::string hostname = "");
207+
std::string hostname = "",
208+
const std::vector<std::pair<std::string, std::string>>
209+
&sslConfCmds = {});
206210

207211
private:
208212
/// Not thread safe, but in loop

trantor/net/TcpConnection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ class TRANTOR_EXPORT TcpConnection
230230
* established.
231231
* @param hostname The server hostname for SNI. If it is empty, the SNI is
232232
* not used.
233+
* @param sslConfCmds The commands used to call the SSL_CONF_cmd function in
234+
* OpenSSL.
233235
*/
234236
virtual void startClientEncryption(
235237
std::function<void()> callback,

trantor/net/TcpServer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ class TRANTOR_EXPORT TcpServer : NonCopyable
202202
* @param keyPath The path of the private key file.
203203
* @param useOldTLS If true, the TLS 1.0 and 1.1 are supported by the
204204
* server.
205+
* @param sslConfCmds The commands used to call the SSL_CONF_cmd function in
206+
* OpenSSL.
205207
* @note It's well known that TLS 1.0 and 1.1 are not considered secure in
206208
* 2020. And it's a good practice to only use TLS 1.2 and above.
207209
*/

0 commit comments

Comments
 (0)