I made a simple TLS Server with GCDAsyncSocket and want to get the clients public key. I tried using this:
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
SSLContextRef ref = [sock sslContext];
SecTrustRef trust;
SSLCopyPeerTrust(ref, &trust);
SecKeyRef key = SecTrustCopyPublicKey(trust);
NSLog(@"%@",key);
}
but i get a exc_bad_access in the SecTrustCopyPublicKey method. How can i get the public key as a NSString/NSData?