证书中未定义的 CommonName
Undefined CommonName in certificate
到目前为止,我一直在使用我添加到 SoapUI 5.2 项目并使我能够访问预生产服务器的证书。但是,现在我已准备好转移到生产环境,我正在尝试使用 SoapUI 检查新的生产证书,但我收到下一个错误:
WARN:Using fallback method to load keystore/truststore due to: Invalid keystore format
ERROR:An error occurred [java.lang.NullPointerException], see error log for details
错误日志显示:
ERROR:Could not load keystore/truststore
ERROR:java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:176)
at org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:97)
at org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:88)
at com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto.fallbackLoad(KeyMaterialWssCrypto.java:206)
at com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto.load(KeyMaterialWssCrypto.java:168)
at com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto.getStatus(KeyMaterialWssCrypto.java:216)
at com.eviware.soapui.impl.wsdl.panels.project.WSSTabPanel$CryptoTableModel.getValueAt(WSSTabPanel.java:643)
at javax.swing.JTable.getValueAt(Unknown Source)
at javax.swing.JTable.prepareRenderer(Unknown Source)
...
我发现预生产证书和生产证书之间的唯一区别是后者没有定义 CommonName 字段。
我知道该字段不是必填字段,那怎么可能呢?如何在不申请新证书的情况下解决这个问题?那不是一个选择。
如有任何建议,我们将不胜感激。
我检查了 5.2 versión 的 SOAPUI 项目 pom.xml
,它使用 not-yet-commons-ssl versión 0.3.11:
<dependency>
<groupId>commons-ssl</groupId>
<artifactId>not-yet-commons-ssl</artifactId>
<version>0.3.11</version>
</dependency>
并且如果您检查 org.apache.commons.ssl.KeyStoreBuilder
class 的 build
方法作为错误日志中抛出的异常,您将看到:
public static KeyStore build(byte[] jksOrCerts, byte[] privateKey,
char[] jksPassword, char[] keyPassword)
throws IOException, CertificateException, KeyStoreException,
NoSuchAlgorithmException, InvalidKeyException,
NoSuchProviderException, ProbablyBadPasswordException,
UnrecoverableKeyException {
...
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null, jksPassword);
Iterator keysIt = keys.iterator();
Iterator chainsIt = chains.iterator();
int i = 1;
while (keysIt.hasNext() && chainsIt.hasNext()) {
Key key = (Key) keysIt.next();
Certificate[] c = (Certificate[]) chainsIt.next();
X509Certificate theOne = buildChain(key, c);
String alias = "alias_" + i++;
// The theOne is not null, then our chain was probably altered.
// Need to trim out the newly introduced null entries at the end of
// our chain.
if (theOne != null) {
c = Certificates.trimChain(c);
alias = Certificates.getCN(theOne);
/* line 176 */ alias = alias.replace(' ', '_');
}
ks.setKeyEntry(alias, key, keyPassword, c);
}
return ks;
}
}
看来你是对的,问题是你的证书没有通用名称,所以 org.apache.commons.ssl.Certificates.getCN(X509Certificate)
returns null
作为别名然后 alias.replace
是扔 NPE
.
alias = Certificates.getCN(theOne);
/* line 176 */ alias = alias.replace(' ', '_');
我没有看到任何内容表明 Common Name
在 RFC5280 中是强制性的,但是各种 code/software 将它用于不同的目的,就像 not-yet-commons-ssl 所做的那样。
你的证书可能是正确的,但如果它没有 CN,你不能将它与 SOAPUI 5.2
版本一起使用来测试你的环境,所以如果你想使用 SOAPUI 来测试你的环境,我认为您必须重新颁发生成带有 CN 的 CSR 的证书。或者您可以将问题报告给 http://juliusdavies.ca/commons-ssl/
然后要求 SOAPUI 包含最新版本...
希望这对您有所帮助,
到目前为止,我一直在使用我添加到 SoapUI 5.2 项目并使我能够访问预生产服务器的证书。但是,现在我已准备好转移到生产环境,我正在尝试使用 SoapUI 检查新的生产证书,但我收到下一个错误:
WARN:Using fallback method to load keystore/truststore due to: Invalid keystore format
ERROR:An error occurred [java.lang.NullPointerException], see error log for details
错误日志显示:
ERROR:Could not load keystore/truststore
ERROR:java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:176)
at org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:97)
at org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:88)
at com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto.fallbackLoad(KeyMaterialWssCrypto.java:206)
at com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto.load(KeyMaterialWssCrypto.java:168)
at com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto.getStatus(KeyMaterialWssCrypto.java:216)
at com.eviware.soapui.impl.wsdl.panels.project.WSSTabPanel$CryptoTableModel.getValueAt(WSSTabPanel.java:643)
at javax.swing.JTable.getValueAt(Unknown Source)
at javax.swing.JTable.prepareRenderer(Unknown Source)
...
我发现预生产证书和生产证书之间的唯一区别是后者没有定义 CommonName 字段。
我知道该字段不是必填字段,那怎么可能呢?如何在不申请新证书的情况下解决这个问题?那不是一个选择。
如有任何建议,我们将不胜感激。
我检查了 5.2 versión 的 SOAPUI 项目 pom.xml
,它使用 not-yet-commons-ssl versión 0.3.11:
<dependency>
<groupId>commons-ssl</groupId>
<artifactId>not-yet-commons-ssl</artifactId>
<version>0.3.11</version>
</dependency>
并且如果您检查 org.apache.commons.ssl.KeyStoreBuilder
class 的 build
方法作为错误日志中抛出的异常,您将看到:
public static KeyStore build(byte[] jksOrCerts, byte[] privateKey,
char[] jksPassword, char[] keyPassword)
throws IOException, CertificateException, KeyStoreException,
NoSuchAlgorithmException, InvalidKeyException,
NoSuchProviderException, ProbablyBadPasswordException,
UnrecoverableKeyException {
...
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null, jksPassword);
Iterator keysIt = keys.iterator();
Iterator chainsIt = chains.iterator();
int i = 1;
while (keysIt.hasNext() && chainsIt.hasNext()) {
Key key = (Key) keysIt.next();
Certificate[] c = (Certificate[]) chainsIt.next();
X509Certificate theOne = buildChain(key, c);
String alias = "alias_" + i++;
// The theOne is not null, then our chain was probably altered.
// Need to trim out the newly introduced null entries at the end of
// our chain.
if (theOne != null) {
c = Certificates.trimChain(c);
alias = Certificates.getCN(theOne);
/* line 176 */ alias = alias.replace(' ', '_');
}
ks.setKeyEntry(alias, key, keyPassword, c);
}
return ks;
}
}
看来你是对的,问题是你的证书没有通用名称,所以 org.apache.commons.ssl.Certificates.getCN(X509Certificate)
returns null
作为别名然后 alias.replace
是扔 NPE
.
alias = Certificates.getCN(theOne);
/* line 176 */ alias = alias.replace(' ', '_');
我没有看到任何内容表明 Common Name
在 RFC5280 中是强制性的,但是各种 code/software 将它用于不同的目的,就像 not-yet-commons-ssl 所做的那样。
你的证书可能是正确的,但如果它没有 CN,你不能将它与 SOAPUI 5.2
版本一起使用来测试你的环境,所以如果你想使用 SOAPUI 来测试你的环境,我认为您必须重新颁发生成带有 CN 的 CSR 的证书。或者您可以将问题报告给 http://juliusdavies.ca/commons-ssl/
然后要求 SOAPUI 包含最新版本...
希望这对您有所帮助,