Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It crashes on MKCertificate *cert = [[conn peerCertificates] objectAtIndex:0]; #36

Open
fbartolom opened this issue Apr 27, 2015 · 1 comment

Comments

@fbartolom
Copy link

When running both the stand-alone app or embedding the library in another project, it crashes in - (void) connection:(MKConnection *)conn trustFailureInCertificateChain:(NSArray *)chain when it tries to take the first object of [conn peerCertificates] as the function returns nil. I peeped inside the function:

// Returns the certificates of the peer of connection. That is, the server's certificate chain.

  • (NSArray *) peerCertificates {
    if (_peerCertificates != nil) {
    return _peerCertificates;
    }
    NSArray *secCerts = (NSArray *) CFWriteStreamCopyProperty((CFWriteStreamRef) _outputStream, kCFStreamSocketSecurityLevelSSLv3);
    _peerCertificates = [[NSMutableArray alloc] initWithCapacity:[secCerts count]];
    [secCerts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    NSData *data = (NSData *) SecCertificateCopyData((SecCertificateRef)obj);
    [_peerCertificates addObject:[MKCertificate certificateWithCertificate:data privateKey:nil]];
    [data release];
    }];
    [secCerts release];

    return _peerCertificates;
    }
    and I noticed it not even entered the enumeration.

@fbartolom
Copy link
Author

As a matter of fact it was due to an attempt to remove the warning on kCFStreamPropertySSLPeerCertificates. Apparently the value I used was not the correct one. What should one employ instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant