Created
April 10, 2022 11:38
-
-
Save iolate/eddf4270361f64b57f0e86ac67125d54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Method 1: Copy | |
let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, derData as CFData) | |
// Method 2: No Copy | |
cert.withUnsafeBytes { unsafeBytes in | |
let bytes = unsafeBytes.bindMemory(to: UInt8.self).baseAddress! | |
let cFData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, bytes, unsafeBytes.count, kCFAllocatorNull)! | |
let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, cFData) | |
} | |
// * certificate is nil if cert is not valid DER-encoded X.509 certificate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment