gpt4 book ai didi

java - 将证书添加到 Mirth Keystore

转载 作者:行者123 更新时间:2023-12-04 22:35:12 26 4
gpt4 key购买 nike

这似乎应该是一件简单的事情。我希望能够信任来自 Mirth 所依赖的服务的证书,而无需修改全局 Java 证书存储(或为 SSL 插件删除每个实例的几个宏)。我尝试了以下方法:

生成我自己的 keystore :

键盘工具命令:

keytool -genkey -keystore appdata\my.jks -storetype PKCS12 -keyalg RSA -keysize 2048 -storepass xxxxxxxx
keytool -importcert -alias my-ca-cert -file myCaCert.pem -keystore appdata\my.jks -trustcacerts -storepass xxxxxxxx
keytool -importcert -alias my-server-cert -file myServerCert.pem -keystore appdata\my.jks -trustcacerts -storepass xxxxxxxx

欢乐属性:
keystore.path = ${dir.appdata}/my.jks
keystore.storepass = xxxxxxxx
keystore.keypass = xxxxxxxx
keystore.type = pkcs12

在这种情况下,Mirth 完全无法启动。日志中的第一个错误是
java.io.IOException: Invalid keystore format
at com.sun.crypto.provider.JceKeyStore.engineLoad(JceKeyStore.java:724)
at java.security.KeyStore.load(Unknown Source)
at com.mirth.connect.server.MirthWebServer.createSSLConnector(MirthWebServer.java:370)
at com.mirth.connect.server.MirthWebServer.<init>(MirthWebServer.java:150)
at com.mirth.connect.server.Mirth.startWebServer(Mirth.java:385)
at com.mirth.connect.server.Mirth.startup(Mirth.java:265)
at com.mirth.connect.server.Mirth.run(Mirth.java:154)

更新 Mirth 内置 keystore :

键盘工具命令:
keytool -importcert -alias my-ca-cert -file myCaCert.pem -keystore appdata\keystore.jks -trustcacerts -storetype jceks -storepass xxxxxxxx
keytool -importcert -alias my-server-cert -file myServerCert.pem -keystore appdata\keystore.jks -trustcacerts -storetype jceks -storepass xxxxxxxx

欢乐属性:
keystore.path = ${dir.appdata}/keystore.jks
keystore.storepass = xxxxxxxx
keystore.keypass = xxxxxxxx
keystore.type = JCEKS

在这种情况下,Mirth 完全启动,但服务器证书无效。错误日志是
DETAILS:    JavaException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at 69352923-b68f-4e96-95a3-ad7681a7f3c1_Deploy:112 (doScript)
at 69352923-b68f-4e96-95a3-ad7681a7f3c1_Deploy:118
at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:547)
at com.mirth.connect.server.util.javascript.JavaScriptUtil$2.doCall(JavaScriptUtil.java:379)
at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

更新 Java 全局 keystore

键盘工具命令:
keytool.exe -importcert -alias my-ca-cert -file myCaCert.pem -keystore cacerts -storepass xxxxxxxx
keytool.exe -importcert -alias my-server-cert -file myServerCert.pem -keystore cacerts -storepass xxxxxxxx

Mirth.properties:(同上)
keystore.path = ${dir.appdata}/keystore.jks
keystore.storepass = xxxxxxxx
keystore.keypass = xxxxxxxx
keystore.type = JCEKS

这可行但不可取,因为它使部署复杂化(我们无法控制客户环境),而且我不相信 Java 升级不会简单地覆盖存储。

最佳答案

通过太多的试验和错误,这是我能够学到的:

  • native Mirth 发送者/接收者自己使用 Mirth.properties 中定义的 Mirth Keystore。如上所述导入证书将适用于这些 channel 。
  • 如果您使用 Rhino 引擎(例如 Java/JavaScript)来发送/接收 http 请求,则忽略 Mirth keystore 并使用全局 Java 存储。同样,上述过程有效。由于我的证书来自 Windows,事实证明我可以通过添加 -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT 来简化一点。到 Mirth.properties,不要让我的现场技术人员使用 Java 的 keytool

  • 我最初没有看到 Mirth channel 工作的原因是因为我的 channel 的部署脚本从身份验证提供者那里获得了访问 token ,并且我没有考虑独立测试 channel 发送者。我不认为我是以编程方式做事还是通过 UI 配置 channel 无关紧要,但是,这对你来说是快乐的。 :/

    无论如何,希望有一天这会对某人有所帮助。

    关于java - 将证书添加到 Mirth Keystore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61419138/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com