Most visited

Recently visited

Added in API level 1
Deprecated since API level 22

X509HostnameVerifier

public interface X509HostnameVerifier
implements HostnameVerifier

org.apache.http.conn.ssl.X509HostnameVerifier
Known Indirect Subclasses


该接口在API级别22中已被弃用。
请改用openConnection() 请访问this webpage了解更多详情。

用于检查主机名是否与存储在服务器的X.509证书内的名称匹配的接口。 实现javax.net.ssl.HostnameVerifier,但我们实际上并未使用该接口。 相反,我们添加了一些采用String参数的方法(而不是javax.net.ssl.HostnameVerifier的SSLSession)。 JUnit通过这种方式很容易! :-)

We provide the HostnameVerifier.DEFAULT, HostnameVerifier.STRICT, and HostnameVerifier.ALLOW_ALL implementations. But feel free to define your own implementation!

Inspired by Sebastian Hauer's original StrictSSLProtocolSocketFactory in the HttpClient "contrib" repository.

Summary

Public methods

abstract void verify(String host, SSLSocket ssl)
abstract void verify(String host, X509Certificate cert)
abstract void verify(String host, String[] cns, String[] subjectAlts)

检查提供的主机名是否与任何提供的CN或“DNS”Subject-Alts匹配。

abstract boolean verify(String host, SSLSession session)

验证主机名是否与服务器的验证方案匹配。

Inherited methods

From interface javax.net.ssl.HostnameVerifier

Public methods

verify

Added in API level 1
void verify (String host, 
                SSLSocket ssl)

Parameters
host String
ssl SSLSocket
Throws
IOException

verify

Added in API level 1
void verify (String host, 
                X509Certificate cert)

Parameters
host String
cert X509Certificate
Throws
SSLException

verify

Added in API level 1
void verify (String host, 
                String[] cns, 
                String[] subjectAlts)

检查提供的主机名是否与任何提供的CN或“DNS”Subject-Alts匹配。 大多数实现仅查看第一个CN,并忽略任何其他CN。 大多数实现都会查看所有“DNS”主题。 根据RFC 2818,CN或Subject-Alts可能包含通配符。

Parameters
host String: The hostname to verify.
cns String: CN fields, in order, as extracted from the X.509 certificate.
subjectAlts String: Subject-Alt fields of type 2 ("DNS"), as extracted from the X.509 certificate.
Throws
SSLException If verification failed.

verify

Added in API level 1
boolean verify (String host, 
                SSLSession session)

验证主机名是否与服务器的验证方案匹配。

Parameters
host String: the host name
session SSLSession: SSLSession used on the connection to host
Returns
boolean true if the host name is acceptable

Hooray!