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
|
@interface SSLSocket: OFTCPSocket
|
||||||
{
|
{
|
||||||
SSL_CTX *ctx;
|
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
BOOL handsShaken;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithSocket: (OFTCPSocket*)socket;
|
- initWithSocket: (OFTCPSocket*)socket;
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
# define INVALID_SOCKET -1
|
# define INVALID_SOCKET -1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static SSL_CTX *ctx;
|
||||||
|
|
||||||
@implementation SSLSocket
|
@implementation SSLSocket
|
||||||
+ (void)load
|
+ (void)load
|
||||||
{
|
{
|
||||||
|
@ -26,29 +28,16 @@
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
if (self == [SSLSocket class])
|
if (self != [SSLSocket class])
|
||||||
SSL_library_init();
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
- init
|
SSL_library_init();
|
||||||
{
|
|
||||||
self = [super init];
|
|
||||||
|
|
||||||
@try {
|
if ((ctx = SSL_CTX_new(SSLv23_method())) == NULL)
|
||||||
if ((ctx = SSL_CTX_new(SSLv23_method())) == NULL)
|
@throw [OFInitializationFailedException newWithClass: self];
|
||||||
@throw [OFInitializationFailedException
|
|
||||||
newWithClass: isa];
|
|
||||||
|
|
||||||
if ((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) &
|
if ((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2) == 0)
|
||||||
SSL_OP_NO_SSLv2) == 0)
|
@throw [OFInitializationFailedException newWithClass: self];
|
||||||
@throw [OFInitializationFailedException
|
|
||||||
newWithClass: isa];
|
|
||||||
} @catch (id e) {
|
|
||||||
[self release];
|
|
||||||
@throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithSocket: (OFTCPSocket*)socket
|
- initWithSocket: (OFTCPSocket*)socket
|
||||||
|
|
Reference in a new issue