使用 Orbeon Forms,为什么我使用自签名证书向服务器提交失败?
当通过 HTTPS 对使用自签名证书的服务器运行提交 (
) 时,我在日志中收到如下所示的异常:
ERROR XFormsServer - XForms - submission - xforms-submit-error throwable: sun.security.provider.certpath.SunCertPathBuilderException
: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
如何解决此问题?
When running submissions (<xforms:submission>
) over HTTPS against a server that use a self-signed certificate, I am getting an exception in the logs that looks like:
ERROR XFormsServer - XForms - submission - xforms-submit-error throwable: sun.security.provider.certpath.SunCertPathBuilderException
: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
How can I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当发出 HTTPS 请求时,Java 会检查服务器的证书。由于证书是自签名的,Java 无法验证它是否是合法证书,因此会出现错误消息“无法找到请求目标的有效证书路径”。
您需要做的是:
执行上述第 2 步的具体步骤取决于您的环境,但本质上是:
如果处理请求的服务器在 Java 密钥存储中拥有其自签名密钥,请将其导出。这里
your-server
是您的服务器密钥存储的别名,mykey.cer
是您正在创建的文件,keystore
是您的密钥存储文件,your-password
是您的密钥存储的密码。keytool -export -alias your-server -file mykey.cer -keystore keystore -storepass your-password
在运行 Orbeon Forms 的服务器上(即发起 HTTPS 请求的服务器) ,将
mykey.cer
导入信任存储区。这里的truststore
是您的信任存储文件,如果您没有现有的信任存储,它可能是您正在创建的新文件。keytool -import -v -trustcacerts -alias your-server -file mykey.cer -keystore truststore -storepass your-password
启动时添加以下
-D
参数运行应用程序服务器(例如 Tomcat)和 Orbeon Forms 的 VM:-Djavax.net.ssl.trustStore=path/to/your/truststore -Djavax.net.ssl.trustStorePassword=your-password
When making the HTTPS request, Java checks the certificate of the server. Because the certificate is self-signed, Java can't verify it is a legitimate certificate, hence the error message "unable to find valid certification path to requested target".
What you need to do is either:
The exact steps for doing #2 above will depend on your environment, but in essence:
If the server handling the requests has its self-signed key in a Java key store, export it. Here
your-server
is the alias for your server the key store,mykey.cer
is the file you are creating,keystore
is your key store file, andyour-password
is the password to your key store.keytool -export -alias your-server -file mykey.cer -keystore keystore -storepass your-password
On the server on which Orbeon Forms is running (i.e. the server that initiates the HTTPS request), import
mykey.cer
into a trust store. Heretruststore
is your trust store file, which might be a new file you are creating if you don't have an existing trust store.keytool -import -v -trustcacerts -alias your-server -file mykey.cer -keystore truststore -storepass your-password
Add the following
-D
parameters when starting the VM that runs your application server (e.g. Tomcat) and Orbeon Forms:-Djavax.net.ssl.trustStore=path/to/your/truststore -Djavax.net.ssl.trustStorePassword=your-password