Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I have Apache2 httpd use the ubuntu's CA cert for outbound SSL connections from Apache?

Note this is not a question about having apache accept inbound SSL connections.

I have an apache module that needs to make outbound SSL connections. When it attempts to, it gets this error:

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:

This is indicating the SSL library that apache is using doesn't know about the (valid) certificate of the server that my module is trying to connect to.

The CA cert on my ubuntu system where this is running is fine, knows about this downstream cert, openssl s_client tells me everything is ok.

How do I tell Apache2 to use ubuntu's system CA cert to make outbound connections work?

update - I did an strace -e open httpd -X to see where it was trying to load certificates from. I see apache opening libssl.so, but then I don't see it even trying to open up the usual ssl.cnf or any certificates file.

snipped useless strace output

update2: As to how I'm creating the https request - I'm making the request from inside my custom apache module. My module .so is written in Rust, so the connection code looks basically like:

in 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
like image 575
marathon Avatar asked Nov 22 '17 23:11

marathon


1 Answers

I found a solution that works, though I'm not sure it is optimal.

openSSL takes the environment variable SSL_CERT_FILE. I can set this in my apache module source code.

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);
like image 192
marathon Avatar answered Sep 28 '22 07:09

marathon