我在调用 https 网络服务时遇到以下异常。
com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present.
我正在从 Java 代码调用 php 网络服务。 CN(通用名称)即证书上的 IP 地址和我调用的 IP 地址不同。我已经在java的 keystore 中添加了证书。 有人可以帮我弄清楚为什么会这样吗?我哪里出错了? CN 是服务器 IP 地址。由于防火墙问题,我正在使用它的外部 IP 地址调用该服务器。
最佳答案
The CN (Common name) i.e. IP on certificate is different and the IP i am calling is different.
...
HTTP transport error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present.
当一个名称出现在通用名称 (CN) 中时,它必须也出现在主题备用名称 (SAN) 中。您的证书格式不正确(并且可能还有其他问题)。参见 Baseline Requirements for the Issuance and Management of Publicly-Trusted Certificates , 第 9 节(第 9 页和第 10 页):
9.2.2 Subject Common Name Field
Certificate Field: subject:commonName (OID 2.5.4.3)
Required/Optional: Deprecated (Discouraged, but not prohibited)
Contents: If present, this field MUST contain a single IP address or Fully-Qualified Domain Name that is one of the values contained in the Certificate’s subjectAltName extension (see Section 9.2.1).
Bruno 可能会引用 RFC 6125 中的相关部分。
关于java - 证书异常 : No subject alternative names present,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22505312/