首页 > 解决方案 > 从外部应用程序到 apache httpd Web 服务器的 httpS 调用问题

问题描述

我们的应用程序 API 部署在 jboss 容器中,并通过 apache httpd Web 服务器(2.4.48)启用访问。外部应用程序正在通过 Web 服务器访问我们的 API。

使用以下配置通过 https 启用 Web 服务器访问

<VirtualHost {SystemIP}:{somePort}>
ServerName abc.org.com
ErrorLog /www/home/logs/error_log
SSLEngine on
SSLCertificateFile /home/apache/http/ssl/server.crt
SSLCertificateKeyFile /home/apache/http/ssl/server.key
SSLCertificateChainFile /home/apache/http/ssl/ca-bundle.crt
...
</VirtualHost>

server.key包含私钥,server.crt包含 CA 签名的服务器证书,ca-bundle.crt包含根证书和中间证书以及由外部应用程序团队共享的外部服务器证书

当他们尝试通过 https ( https://abc.org.com )访问我们的 API 时,客户端应用程序的PKIX 路径构建失败

从我们的 apache 服务器 ssl 日志显示以下错误

[Mon Sep 06 05:34:54.321808 2021] [ssl:info] [pid 111:tid 12345] [client 160.82.161.2:46108] AH02008: SSL library error 1 in handshake (server ...)
[Mon Sep 06 05:34:54.321860 2021] [ssl:info] [pid 111:tid 140138261788416] SSL Library Error: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown (SSL alert number 46)

但是我们可以从浏览器访问https://abc.org.com并且证书工作正常。

我们在这里缺少什么?在哪里将外部应用程序证书添加到 Web 服务器?

客户端 SSL 日志

***
%% Invalidated:  [Session-6, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384]
ExternalApplication-1, SEND TLSv1.2 ALERT:  fatal, description = certificate_unknown
ExternalApplication-1, WRITE: TLSv1.2 Alert, length = 2
[Raw write]: length = 7
0000: 15 03 03 00 02 02 2E                               .......
ExternalApplication-1, called closeSocket()
ExternalApplication-1, handling exception: 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

2021-09-02 14:57:00.944 ERROR [ExternalApplication-1] c.d.p.AccountHolder - Error while processing AccountHolder serviceI/O error on POST request for "abc.com/apiPath": sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

标签: apachessl

解决方案


正如 ezra-s 正确指出的那样,客户端应用程序中的证书加载存在问题。正确导入证书后,问题已解决。


推荐阅读