Closed CraigSiemens closed 3 years ago
Hello and thanks for the bug report!
The copyPublicKeyFromCertificate function is only called by hashSubjectPublicKeyInfoFromCertificate, which can already return nil if something went wrong.
Hence, one option would be to return nil in copyPublicKeyFromCertificate and then nil again in hashSubjectPublicKeyInfoFromCertificate, which would cause TrustKit's validation to fail and reject the connection.
Hence, the app still wouldn't work, but it wouldn't crash.
There's another crash that's been appearing in our app. So far it's only happened a handful of times but they've all been iOS >= 14.4, but the majority of our user base is on those versions so it might not be relevant.
I looked through the code and it appears that the returned
OSStatus
from callingSecTrustCreateWithCertificates
is not checked. If it fails for any reasons, it still tries to release thetrust
variable which may not have been set. I also noticed the the following call toSecTrustEvaluate
doesn't check theresult
or the returnedOSStatus
either which is probably an issue as well.I'd be willing to try fixing it but I'm not sure what kind of affect returning
nil
fromcopyPublicKeyFromCertificate:
would have on the other places calling it.