如何修复“java.security.cert.CertificateException:不存在使用者替代名称”错误?
2022-08-31 07:49:05
我有一个Java Web服务客户端,它通过HTTPS使用Web服务。
import javax.xml.ws.Service;
@WebServiceClient(name = "ISomeService", targetNamespace = "http://tempuri.org/", wsdlLocation = "...")
public class ISomeService
extends Service
{
public ISomeService() {
super(__getWsdlLocation(), ISOMESERVICE_QNAME);
}
当我连接到服务URL( )时,我得到异常。https://AAA.BBB.CCC.DDD:9443/ISomeService
java.security.cert.CertificateException: No subject alternative names present
为了解决这个问题,我首先运行并在文件中获取了以下内容:openssl s_client -showcerts -connect AAA.BBB.CCC.DDD:9443 > certs.txt
certs.txt
CONNECTED(00000003)
---
Certificate chain
0 s:/CN=someSubdomain.someorganisation.com
i:/CN=someSubdomain.someorganisation.com
-----BEGIN CERTIFICATE-----
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=someSubdomain.someorganisation.com
issuer=/CN=someSubdomain.someorganisation.com
---
No client certificate CA names sent
---
SSL handshake has read 489 bytes and written 236 bytes
---
New, TLSv1/SSLv3, Cipher is RC4-MD5
Server public key is 512 bit
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : RC4-MD5
Session-ID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Session-ID-ctx:
Master-Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Key-Arg : None
Start Time: 1382521838
Timeout : 300 (sec)
Verify return code: 21 (unable to verify the first certificate)
---
AFAIK,现在我需要
- 提取 和 之间的部分,
certs.txt
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
- 修改它,使证书名称等于和
AAA.BBB.CCC.DDD
- 然后使用导入结果(其中是操作 1 和 2 的结果)。
keytool -importcert -file fileWithModifiedCertificate
fileWithModifiedCertificate
这是正确的吗?
如果是这样,我究竟如何使步骤1中的证书与基于IP的address()一起使用?AAA.BBB.CCC.DDD
更新 1 (23.10.2013 15:37 MSK):在回答类似问题时,我读到了以下内容:
如果您无法控制该服务器,请使用其主机名(前提是现有证书中至少有一个与该主机名匹配的 CN)。
“使用”到底是什么意思?