Have one global ctx.
This commit is contained in:
parent
2323d59613
commit
6e5b389529
2 changed files with 9 additions and 22 deletions
|
@ -4,9 +4,7 @@
|
|||
|
||||
@interface SSLSocket: OFTCPSocket
|
||||
{
|
||||
SSL_CTX *ctx;
|
||||
SSL *ssl;
|
||||
BOOL handsShaken;
|
||||
}
|
||||
|
||||
- initWithSocket: (OFTCPSocket*)socket;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
# define INVALID_SOCKET -1
|
||||
#endif
|
||||
|
||||
static SSL_CTX *ctx;
|
||||
|
||||
@implementation SSLSocket
|
||||
+ (void)load
|
||||
{
|
||||
|
@ -26,29 +28,16 @@
|
|||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [SSLSocket class])
|
||||
if (self != [SSLSocket class])
|
||||
return;
|
||||
|
||||
SSL_library_init();
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
@try {
|
||||
if ((ctx = SSL_CTX_new(SSLv23_method())) == NULL)
|
||||
@throw [OFInitializationFailedException
|
||||
newWithClass: isa];
|
||||
@throw [OFInitializationFailedException newWithClass: self];
|
||||
|
||||
if ((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) &
|
||||
SSL_OP_NO_SSLv2) == 0)
|
||||
@throw [OFInitializationFailedException
|
||||
newWithClass: isa];
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
}
|
||||
|
||||
return self;
|
||||
if ((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2) == 0)
|
||||
@throw [OFInitializationFailedException newWithClass: self];
|
||||
}
|
||||
|
||||
- initWithSocket: (OFTCPSocket*)socket
|
||||
|
|
Reference in a new issue