git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35624 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-10-03 08:27:45 +00:00
parent b4d7e566f7
commit 42ce2c390d

View file

@ -182,23 +182,12 @@ threadid_function()
- (NSString*) sslSetOptions: (NSDictionary*)options; - (NSString*) sslSetOptions: (NSDictionary*)options;
@end @end
static BOOL permitSSLv2 = NO;
static NSString *cipherList = nil;
@implementation GSSSLHandle @implementation GSSSLHandle
+ (void) _defaultsChanged: (NSNotification*)n
{
permitSSLv2
= [[NSUserDefaults standardUserDefaults] boolForKey: @"GSPermitSSLv2"];
cipherList
= [[NSUserDefaults standardUserDefaults] stringForKey: @"GSCipherList"];
}
+ (void) initialize + (void) initialize
{ {
if (self == [GSSSLHandle class]) if (self == [GSSSLHandle class])
{ {
NSUserDefaults *defs;
unsigned count; unsigned count;
SSL_library_init(); SSL_library_init();
@ -227,14 +216,6 @@ static NSString *cipherList = nil;
inf = [[[NSProcessInfo processInfo] globallyUniqueString] UTF8String]; inf = [[[NSProcessInfo processInfo] globallyUniqueString] UTF8String];
RAND_seed(inf, strlen(inf)); RAND_seed(inf, strlen(inf));
} }
defs = [NSUserDefaults standardUserDefaults];
permitSSLv2 = [defs boolForKey: @"GSPermitSSLv2"];
cipherList = [defs stringForKey: @"GSCipherList"];
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(_defaultsChanged:)
name: NSUserDefaultsDidChangeNotification
object: nil];
} }
} }
@ -302,15 +283,8 @@ static NSString *cipherList = nil;
if (0 == ctx) if (0 == ctx)
{ {
ctx = SSL_CTX_new(SSLv23_client_method()); ctx = SSL_CTX_new(SSLv23_client_method());
if (permitSSLv2 == NO)
{
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2); SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
} }
if (nil != cipherList)
{
SSL_CTX_set_cipher_list(ctx, [cipherList UTF8String]);
}
}
if (0 == ssl) if (0 == ssl)
{ {
ssl = SSL_new(ctx); ssl = SSL_new(ctx);
@ -380,15 +354,8 @@ static NSString *cipherList = nil;
if (ctx == 0) if (ctx == 0)
{ {
ctx = SSL_CTX_new(SSLv23_method()); ctx = SSL_CTX_new(SSLv23_method());
if (permitSSLv2 == NO)
{
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2); SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
} }
if (nil != cipherList)
{
SSL_CTX_set_cipher_list(ctx, [cipherList UTF8String]);
}
}
if ([PEMpasswd length] > 0) if ([PEMpasswd length] > 0)
{ {
SSL_CTX_set_default_passwd_cb_userdata(ctx, SSL_CTX_set_default_passwd_cb_userdata(ctx,