我如何让Apache2 httpd使用ubuntu的CA证书进行Apache的出站SSL连接?

mar*_*hon 7 apache ubuntu ssl https

请注意,这不是关于让apache接受入站SSL连接的问题.

我有一个需要进行出站SSL连接的apache模块.当它尝试时,它会收到此错误:

Failed to send events: The OpenSSL library reported an error: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed:s3_clnt.c:1269:

这表明apache正在使用的SSL库不知道我的模块尝试连接的服务器的(有效)证书.

我运行的ubuntu系统上的CA证书很好,知道这个下游证书,openssl s_client告诉我一切正常.

如何告诉Apache2使用ubuntu的系统CA证书使出站连接有效?

更新 - 我做了一个strace -e open httpd -X,看看它试图从哪里加载证书.我看到apache打开libssl.so,但后来我甚至没有看到它试图打开通常的ssl.cnf或任何证书文件.

snipped useless strace output

update2:至于我是如何创建https请求的 - 我是从我的自定义apache模块中发出请求的.我的模块.so是用Rust编写的,所以连接代码基本上看起来像:

在mod_mine.so中:

use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::reactor::Core;

let mut core = Core::new()?;
let handle = core.handle();
let client = Client::configure()
    .connector(HttpsConnector::new(4, &handle)?)
    .build(&handle);

//actually a POST, but this gets the same error
let request = client.get("https://saas.mycompany.io".parse()?);
let result = core.run(request)?;
...  //process result
Run Code Online (Sandbox Code Playgroud)

mar*_*hon 1

我找到了一个可行的解决方案,尽管我不确定它是否是最佳的。

openSSL 采用环境变量SSL_CERT_FILE。我可以在我的 apache 模块源代码中设置它。

use std::env;
let cert_file = figure_out_cert_path();  //on ubuntu:  /etc/ssl/certs/ca-certificates.crt
env::set_var("SSL_CERT_FILE", cert_file);
Run Code Online (Sandbox Code Playgroud)