From 2c6ef4d9691618ed4d46c8c41e8a7cf1ab3e1060 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Mon, 13 Jun 2011 18:14:19 +0200 Subject: [PATCH] Use certificate / key in client mode if set. --- src/SSLSocket.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SSLSocket.m b/src/SSLSocket.m index de63d5c..0c52f40 100644 --- a/src/SSLSocket.m +++ b/src/SSLSocket.m @@ -79,7 +79,11 @@ static SSL_CTX *ctx; SSL_set_connect_state(ssl); - if (SSL_connect(ssl) != 1) { + if ((privateKeyFile != nil && !SSL_use_PrivateKey_file(ssl, + [privateKeyFile cString], SSL_FILETYPE_PEM)) || + (certificateFile != nil && !SSL_use_certificate_file(ssl, + [certificateFile cString], SSL_FILETYPE_PEM)) || + SSL_connect(ssl) != 1) { close(sock); sock = INVALID_SOCKET; @throw [OFInitializationFailedException @@ -122,7 +126,11 @@ static SSL_CTX *ctx; SSL_set_connect_state(ssl); - if (SSL_connect(ssl) != 1) { + if ((privateKeyFile != nil && !SSL_use_PrivateKey_file(ssl, + [privateKeyFile cString], SSL_FILETYPE_PEM)) || + (certificateFile != nil && !SSL_use_certificate_file(ssl, + [certificateFile cString], SSL_FILETYPE_PEM)) || + SSL_connect(ssl) != 1) { [super close]; @throw [OFConnectionFailedException newWithClass: isa socket: self