Skip to content

Instantly share code, notes, and snippets.

View dimebt's full-sized avatar
🎯
Focusing

Dimitar Stefanovski dimebt

🎯
Focusing
View GitHub Profile
@dimebt
dimebt / CertificatePinning.swift
Created January 29, 2023 21:40 — forked from pallavtrivedi03/CertificatePinning.swift
Implementation of SSL pinning (using certifcate)
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard let serverTrust = challenge.protectionSpace.serverTrust else {
completionHandler(.cancelAuthenticationChallenge, nil);
return
}
let certificate = SecTrustGetCertificateAtIndex(serverTrust, 0)
// SSL Policies for domain name check
let policy = NSMutableArray()