Tag: 证书 机构

SSL Socket连接iOS

我想build立一个安全的连接到一个Java运行SSLServerSocket。 我已经创build了自己的根CA,并签署了使用此证书的Java SSLServerSocket的证书。 我想将这个根证书添加到我的应用程序,以便由根证书签名的任何证书将工作。 到目前为止,我有安全的连接工作正常通过设置读取和写入stream属性为: NSDictionary *settings = [[NSDictionary alloc] initWithObjectsAndKeys: (id)kCFStreamSocketSecurityLevelNegotiatedSSL, kCFStreamPropertySocketSecurityLevel, [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates, [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredRoots, [NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,nil]; 我将证书添加到钥匙串中,如下所示: -(void)addRootCert{ NSString* rootCertPath = [[NSBundle mainBundle] pathForResource:@"rootCA" ofType:@"der"]; NSData* rootCertData = [NSData dataWithContentsOfFile:rootCertPath]; OSStatus err = noErr; SecCertificateRef rootCert = SecCertificateCreateWithData(kCFAllocatorDefault, (__bridge CFDataRef)rootCertData); NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:(__bridge_transfer id)kSecClassCertificate, kSecClass, rootCert, kSecValueRef, […]