Java密钥库:如何正确导入ca证书?

我们已经更新了我们的一个服务器(apache httpd)的证书。 对于web服务接口(对于移动客户端),我们还需要在tomcat上使用证书,意思是:存储在一个java密钥库中。 我们在java密钥库上已经有了我们的证书,但是根证书仍然缺失。

如果我们列出旧密钥库证书的详细信息,我们会得到:

/> keytool -list -v -keystore 2012.jks -alias ourcertificate Keystore-Kennwort eingeben: Aliasname: ourcertificate ... ... ... Zertifikatkettenlänge: 3 // certificate length: 3 Zertifikat[1]: // certificate[1] ... ... ... Zertifikat[2]: ... ... ... Zertifikat[3]: ... ... ... 

重要的是,所有的ca证书都已经是keystore的“我们证书”别名的一部分。

如果我们列出(新的密钥库文件的)新证书的细节,我们得到:

 /> keytool -list -v -keystore 2015.jks -alias ourcertificate Keystore-Kennwort eingeben: Aliasname: ourcertificate ... ... ... Zertifikatkettenlänge: 1 // certificate length: 1 Zertifikat[1]: // certificate[1] ... ... ... 

ca证书在这里丢失。 要导入CA证书,我们尝试以下命令:

 /> keytool -import -alias alpha -file gsalphasha2g2r1.der -keystore 2015.jks Keystore-Kennwort eingeben: ... ... ... Diesem Zertifikat vertrauen? [Nein]: Ja // trust this certificate? [No]: Yes Zertifikat wurde Keystore hinzugefügt // certificate successfully added to keystroe 

但是这会将新的可信证书添加到密钥库(使用新的别名)。 另外添加根ca certifiacte不帮助。 如果我们列出“ourcertificate”条目的证书详细信息,我们仍然得到一个证书长度1.同时在导入ca证书时指定“ourcertificate”不会有帮助(我们会得到一个错误,即答案和密钥库中的公钥是不完全相同;在德语中的“Keytool-Fehler:java.lang.Exception:公钥在Antwort und Keystore stimmen nichtüberein”中)

怎么了? 我们如何将ca证书导入到java密钥库中以便将ca证书链接到“ourcertificate”

编辑

我想我也必须描述我们如何导入私钥和证书对。 这有点困难,因为CSR是用openssl做的。 我们需要将私钥和证书导入密钥库文件。 为此,我们使用了以下Java类文件: http ://www.agentbob.info/agentbob/79-AB.html(ImportKey类)。 我们知道这是有效的。 但可能是导入密钥和证书时出错…