mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Add GSTLSServerName option
This commit is contained in:
parent
09da1e6894
commit
ed286536e2
8 changed files with 91 additions and 7 deletions
|
@ -1112,6 +1112,7 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
GSTLSPriority,
|
||||
GSTLSRemoteHosts,
|
||||
GSTLSRevokeFile,
|
||||
GSTLSServerName,
|
||||
GSTLSVerify,
|
||||
nil];
|
||||
}
|
||||
|
@ -1127,6 +1128,21 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
[opts setObject: str forKey: key];
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is no value set for the server name, and the host in the
|
||||
* URL is a domain name rather than an address, we use that.
|
||||
*/
|
||||
if (nil == [opts objectForKey: GSTLSServerName])
|
||||
{
|
||||
NSString *host = [u host];
|
||||
unichar c = [host length] == 0 ? 0 : [host characterAtIndex: 0];
|
||||
|
||||
if (c != 0 && c != ':' && !isdigit(c))
|
||||
{
|
||||
[opts setObject: host forKey: GSTLSServerName];
|
||||
}
|
||||
}
|
||||
|
||||
if (debug) [opts setObject: @"YES" forKey: GSTLSDebug];
|
||||
[sock sslSetOptions: opts];
|
||||
[opts release];
|
||||
|
|
|
@ -455,6 +455,7 @@ static NSArray *keys = nil;
|
|||
GSTLSPriority,
|
||||
GSTLSRemoteHosts,
|
||||
GSTLSRevokeFile,
|
||||
GSTLSServerName,
|
||||
GSTLSVerify,
|
||||
nil];
|
||||
[[NSObject leakAt: &keys] release];
|
||||
|
|
|
@ -36,6 +36,7 @@ extern NSString * const GSTLSDebug;
|
|||
extern NSString * const GSTLSPriority;
|
||||
extern NSString * const GSTLSRemoteHosts;
|
||||
extern NSString * const GSTLSRevokeFile;
|
||||
extern NSString * const GSTLSServerName;
|
||||
extern NSString * const GSTLSVerify;
|
||||
|
||||
#if defined(HAVE_GNUTLS)
|
||||
|
|
|
@ -81,6 +81,7 @@ NSString * const GSTLSDebug = @"GSTLSDebug";
|
|||
NSString * const GSTLSPriority = @"GSTLSPriority";
|
||||
NSString * const GSTLSRemoteHosts = @"GSTLSRemoteHosts";
|
||||
NSString * const GSTLSRevokeFile = @"GSTLSRevokeFile";
|
||||
NSString * const GSTLSServerName = @"GSTLSServerName";
|
||||
NSString * const GSTLSVerify = @"GSTLSVerify";
|
||||
|
||||
#if defined(HAVE_GNUTLS)
|
||||
|
@ -1533,6 +1534,32 @@ retrieve_callback(gnutls_session_t session,
|
|||
if (YES == outgoing)
|
||||
{
|
||||
gnutls_init(&session, GNUTLS_CLIENT);
|
||||
|
||||
str = [opts objectForKey: GSTLSServerName];
|
||||
if ([str length] > 0)
|
||||
{
|
||||
const char *ptr = [str UTF8String];
|
||||
unsigned len = strlen(ptr);
|
||||
int ret;
|
||||
|
||||
ret = gnutls_server_name_set(session, GNUTLS_NAME_DNS, ptr, len);
|
||||
if (YES == debug)
|
||||
{
|
||||
if (ret < 0)
|
||||
{
|
||||
NSLog(@"%@ %@: failed '%s'", self, GSTLSServerName,
|
||||
gnutls_strerror(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%@ %@: set to '%s'", self, GSTLSServerName, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (YES == debug)
|
||||
{
|
||||
NSLog(@"%@ %@: not set", self, GSTLSServerName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -882,6 +882,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
GSTLSPriority,
|
||||
GSTLSRemoteHosts,
|
||||
GSTLSRevokeFile,
|
||||
GSTLSServerName,
|
||||
GSTLSVerify,
|
||||
nil];
|
||||
}
|
||||
|
@ -896,6 +897,20 @@ static NSURLProtocol *placeholder = nil;
|
|||
[this->output setProperty: str forKey: key];
|
||||
}
|
||||
}
|
||||
/* If there is no value set for the server name, and the host in the
|
||||
* URL is a domain name rather than an address, we use that.
|
||||
*/
|
||||
if (nil == [this->output propertyForKey: GSTLSServerName])
|
||||
{
|
||||
NSString *host = [url host];
|
||||
unichar c;
|
||||
|
||||
c = [host length] == 0 ? 0 : [host characterAtIndex: 0];
|
||||
if (c != 0 && c != ':' && !isdigit(c))
|
||||
{
|
||||
[this->output setProperty: host forKey: GSTLSServerName];
|
||||
}
|
||||
}
|
||||
if (_debug) [this->output setProperty: @"YES" forKey: GSTLSDebug];
|
||||
}
|
||||
[this->input setDelegate: self];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue