Most visited

Recently visited

Added in API level 17

X509TrustManagerExtensions

public class X509TrustManagerExtensions
extends Object

java.lang.Object
   ↳ android.net.http.X509TrustManagerExtensions


X509TrustManager包装提供了Android添加的功能。

checkServerTrusted方法允许调用者在证书链已经被平台成功验证后对其执行附加验证。

Summary

Public constructors

X509TrustManagerExtensions(X509TrustManager tm)

构造一个新的X509TrustManagerExtensions包装器。

Public methods

List<X509Certificate> checkServerTrusted(X509Certificate[] chain, String authType, String host)

验证给定的证书链。

boolean isUserAddedCertificate(X509Certificate cert)

检查用户是否添加CA证书。

Inherited methods

From class java.lang.Object

Public constructors

X509TrustManagerExtensions

Added in API level 17
X509TrustManagerExtensions (X509TrustManager tm)

构造一个新的X509TrustManagerExtensions包装器。

Parameters
tm X509TrustManager: A X509TrustManager as returned by TrustManagerFactory.getInstance();
Throws
IllegalArgumentException If tm is an unsupported TrustManager type.

Public methods

checkServerTrusted

Added in API level 17
List<X509Certificate> checkServerTrusted (X509Certificate[] chain, 
                String authType, 
                String host)

验证给定的证书链。

有关链和authType参数的描述,请参见checkServerTrusted(X509Certificate[], String) 最后一个参数host,应该是服务器的主机名。

Parameters
chain X509Certificate
authType String
host String
Returns
List<X509Certificate> the properly ordered chain used for verification as a list of X509Certificates.
Throws
CertificateException if the chain does not verify correctly.

isUserAddedCertificate

Added in API level 21
boolean isUserAddedCertificate (X509Certificate cert)

检查用户是否添加CA证书。

由于 checkServerTrusted(X509Certificate[], String)可能允许其参数 chain链接到用户添加的CA证书,因此可以使用此方法为用户添加的CA证书执行其他策略。

Parameters
cert X509Certificate
Returns
boolean true to indicate that the certificate authority exists in the user added certificate store, false otherwise.

Hooray!