NSURLAuthenticationMethodServerTrust 只是 authenticationMethod 的冰山一角 要理解 NSURLAuthenticationMethodServerTrust, 首先要明白它只是 authenticationMethod 的選項之一, 并非唯一 1 · 先厘清概念 點說明authenticationMethodURLAuthenticationChallenge.protectionSpace.authenticationMethod 字符串,用來指明當前“質詢”要求的 認證手段。ServerTrust其中 一個 選項,代表 “請評估服務器證書鏈”。不是它無所不能,而是它只負責 TLS 證書校驗。 2 · 常見 6 大 authenticationMethod 常量用途典型場景NSURLAuthenticationMethodServerTrust服務器證書鏈評估HTTPS / SSL PinningNSURLAuthenticationMethodHTTPBasic明文 Base-64 用戶名密碼內網調試、老式接口NSURLAuthenticationMethodHTTPDigestMD5 摘要口令早期 REST 服務NSURLAuthenticationMethodClientCertificate雙向 TLS,客戶端證書企業內部、銀行 AppNSURLAuthenticationMethodNTLMWindo