1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_WEB_WEB_STATE_WK_WEB_VIEW_SECURITY_UTIL_H_
6 #define IOS_WEB_WEB_STATE_WK_WEB_VIEW_SECURITY_UTIL_H_
8 #import <Foundation/Foundation.h>
10 #include "base/memory/ref_counted.h"
14 class X509Certificate
;
19 // NSErrorPeerCertificateChainKey from NSError's userInfo dict.
20 extern NSString
* const kNSErrorPeerCertificateChainKey
;
22 // Creates a certificate from an array of SecCertificateRef objects.
23 // Returns null if |certs| is nil or empty.
24 scoped_refptr
<net::X509Certificate
> CreateCertFromChain(NSArray
* certs
);
26 // Creates a certificate from a SecTrustRef object.
27 // Returns null if trust is null or does not have any certs.
28 scoped_refptr
<net::X509Certificate
> CreateCertFromTrust(SecTrustRef trust
);
30 // Makes SecTrustEvaluate call to return kSecTrustResultProceed.
31 // Should be called only if the user expilitely agreed to proceed with |trust|
32 // or trust represents a valid certificate chain.
33 void EnsureFutureTrustEvaluationSucceeds(SecTrustRef trust
);
35 // Returns YES if geven error is a SSL error.
36 BOOL
IsWKWebViewSSLError(NSError
* error
);
38 // Fills SSLInfo object with information extracted from |error|. Callers are
39 // responsible to ensure that given |error| is an SSL error by calling
40 // |web::IsSSLError| function.
41 void GetSSLInfoFromWKWebViewSSLError(NSError
* error
, net::SSLInfo
* ssl_info
);
45 #endif // IOS_WEB_WEB_STATE_WK_WEB_VIEW_SECURITY_UTIL_H_