From 04c34a8c7528e5fa0765b38ff6effe767a1713d3 Mon Sep 17 00:00:00 2001 From: rfm Date: Wed, 2 Sep 2015 17:23:07 +0000 Subject: [PATCH] add gnustlsFileSystemRepresentation for mingw git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38965 72102866-910b-0410-8b05-ffd578937521 --- Source/GSTLS.m | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/Source/GSTLS.m b/Source/GSTLS.m index 4028351c3..7c0e8d8d8 100644 --- a/Source/GSTLS.m +++ b/Source/GSTLS.m @@ -42,6 +42,35 @@ #import "GSPrivate.h" +@interface NSString(gnutlsFileSystemRepresentation) +- (const char*) gnutlsFileSystemRepresentation; +@end + +@implementation NSString(gnutlsFileSystemRepresentation) +- (const char*) gnutlsFileSystemRepresentation +{ +#if defined(__MINGW__) + const unichar *buf = (const unichar*)[self fileSystemRepresentation]; + int len = 0; + NSString *str; + const char *result; + + while (buf[len] > 0) + { + len++; + } + str = [[NSString alloc] initWithBytes: buf + length: len * 2 + encoding: NSUnicodeStringEncoding]; + result = [str UTF8String]; + RELEASE(str); + return result; +#else + return [self fileSystemRepresentation]; +#endif +} +@end + /* Constants to control TLS/SSL (options). */ NSString * const GSTLSCAFile = @"GSTLSCAFile"; @@ -1045,7 +1074,7 @@ static NSMutableDictionary *credentialsCache = nil; const char *path; int ret; - path = [dca fileSystemRepresentation]; + path = [dca gnutlsFileSystemRepresentation]; ret = gnutls_certificate_set_x509_trust_file(c->certcred, path, GNUTLS_X509_FMT_PEM); if (ret < 0) @@ -1074,7 +1103,7 @@ static NSMutableDictionary *credentialsCache = nil; const char *path; int ret; - path = [dca fileSystemRepresentation]; + path = [dca gnutlsFileSystemRepresentation]; ret = gnutls_certificate_set_x509_trust_file(c->certcred, path, GNUTLS_X509_FMT_PEM); if (ret < 0) @@ -1106,7 +1135,7 @@ static NSMutableDictionary *credentialsCache = nil; const char *path; int ret; - path = [drv fileSystemRepresentation]; + path = [drv gnutlsFileSystemRepresentation]; ret = gnutls_certificate_set_x509_crl_file(c->certcred, path, GNUTLS_X509_FMT_PEM); if (ret < 0) @@ -1130,7 +1159,7 @@ static NSMutableDictionary *credentialsCache = nil; const char *path; int ret; - path = [rv fileSystemRepresentation]; + path = [rv gnutlsFileSystemRepresentation]; ret = gnutls_certificate_set_x509_crl_file(c->certcred, path, GNUTLS_X509_FMT_PEM); if (ret < 0) @@ -1468,8 +1497,6 @@ static NSMutableDictionary *credentialsCache = nil; } else if ([pri isEqual: NSStreamSocketSecurityLevelSSLv3] == YES) { - GSOnceMLog(@"NSStreamSocketSecurityLevelSSLv3 is insecure ..." - @" please change your code to stop using it"); #if GNUTLS_VERSION_NUMBER < 0x020C00 const int proto_prio[2] = { GNUTLS_SSL3, @@ -1479,6 +1506,8 @@ static NSMutableDictionary *credentialsCache = nil; gnutls_priority_set_direct(session, "NORMAL:-VERS-TLS-ALL:+VERS-SSL3.0", NULL); #endif + GSOnceMLog(@"NSStreamSocketSecurityLevelSSLv3 is insecure ..." + @" please change your code to stop using it"); } else if ([pri isEqual: NSStreamSocketSecurityLevelTLSv1] == YES) {