# SSL-certificate check fails on local opal.login connection

**URL:** <https://datashield.discourse.group/t/ssl-certificate-check-fails-on-local-opal-login-connection/514>\
**Category:** Beginner Support\
**Created:** [24 February 2022 10:42 UTC](https://datashield.discourse.group/t/ssl-certificate-check-fails-on-local-opal-login-connection/514 "2022-02-24T10:42:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![duscha](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@duscha](https://datashield.discourse.group/u/duscha)\
**Post date:** [24 February 2022 10:42 UTC](https://datashield.discourse.group/t/ssl-certificate-check-fails-on-local-opal-login-connection/514/1 "2022-02-24T10:42:47Z")

</div>

Hi,

having configured a reverse proxy based on Apache2, I installed a properly signed (by the well known Telekom AG CA) certificate. Mozilla Firefox and Google Chrome assert that the TLS-connection is secure.

```auto
SSLProxyEngine on
SSLProxyCheckPeerCN off

ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://datashield.research.dhm.mhn.de:8443/
ProxyPassReverse / https://datashield.research.dhm.mhn.de:8443/

```

From a remote server I can establish a OPAL-connection in R:

```auto
> library(opalr)
Loading required package: httr
> o <- opal.login(username = "administrator", password = "SECRET", url = "https://datashield.research.dhm.mhn.de")

```

Locally, on the datashield/Opal server, I can’t connect. Neither on the Apache-reverse proxy, port 443

```auto
> library(opalr)
Loading required package: httr
> o <- opal.login(username = "administrator", password = "SECRET", url = "https://datashield.research.dhm.mhn.de")
Error in curl::curl_fetch_memory(url, handle = handle) : 
  SSL certificate problem: unable to get local issuer certificate

```

nor directly on the OPAL listening port 8443, though, the definite SSL error message differs:

```auto
> library(opalr)
Loading required package: httr
> o <- opal.login(username = "administrator", password = "SECRET", url = "https://datashield.research.dhm.mhn.de:8443")
Error in curl::curl_fetch_memory(url, handle = handle) : 
  SSL certificate problem: self signed certificate

```

(1) Why should the connection on port 443 with the reverse proxy not work locally, and complain about not finding the certificate, if it works remotely?

(2) I don’t understand why the local connection complains about a self-signed certificate. I removed the distribution-created “snakeoil” certificate and key file.

The apache2 error log, /var/log/apache2/error.log, shows:

```auto
[Thu Feb 24 11:21:57.639457 2022] [ssl:warn] [pid 23610:tid 139780264236800] AH02268: Proxy client certificate callback: (datashield.research.dhm.mhn.de:443) downstream server wanted client certificate but none are configured

```

When I added in the proxy configuration section

```auto
SSLProxyMachineCertificateFile /etc/ssl/certs/datashield.research.dhm.mhn.pem 

```

Apache2 complains about

```auto
[Thu Feb 24 11:26:38.646484 2022] [mpm_event:notice] [pid 23608:tid 139780514364480] AH00491: caught SIGTERM, shutting down
AH02252: incomplete client cert configured for SSL proxy (missing or encrypted private key?)

```

Therefore I combined the certificate pem-file and key-file into one pem-file:

```auto
cat /etc/ssl/certs/datashield.research.dhm.mhn.pem /etc/ssl/private/datashield.research.dhm.mhn.key > /etc/ssl/certs/datashield.research.dhm.mhn-withkey.pem

```

The end of line characters are “^M” in the combined file, if that makes a differences.

And configuring this in the proxy reverse section:

```auto
		# Reverse proxy configuration
		SSLProxyEngine on
		SSLProxyCheckPeerCN off
		SSLProxyMachineCertificateFile /etc/ssl/certs/datashield.research.dhm.mhn-withkey.pem 

		ProxyRequests Off
		ProxyPreserveHost On
		ProxyPass / https://datashield.research.dhm.mhn.de:8443/
		ProxyPassReverse / https://datashield.research.dhm.mhn.de:8443/

```

This did not solv the Apache2 problem, and the reported error was the same:

```auto
AH02252: incomplete client cert configured for SSL proxy (missing or encrypted private key?)
[Thu Feb 24 11:29:59.619826 2022] [ssl:emerg] [pid 23974:tid 140354068458560] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
AH00016: Configuration Failed

```

How can this (local) reverse proxy be solved?

Best regards,

Sven

---

<div class="post-metadata">

**Author:** ![duscha](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@duscha](https://datashield.discourse.group/u/duscha)\
**Post date:** [24 February 2022 10:51 UTC](https://datashield.discourse.group/t/ssl-certificate-check-fails-on-local-opal-login-connection/514/2 "2022-02-24T10:51:27Z")

</div>

Hi,

although it seems to be the other way around in my case, searching for the error message “apache2 incomplete client cert configured for SSL proxy (missing or encrypted private key?” in a search engine leads to:

> <https://serverfault.com/questions/660691/sslproxycacertificatefile-fails-incomplete-client-cert-configured-for-ssl-proxy>

I **removed** “RSA” in the section:

```auto
-----BEGIN PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-CBC,CC74335C3E766FF1

```

and then restarting Apache2 with the option “SSLProxyMachineCertificateFile” worked. But the local opal.login-connection still fails with the same SSL error:

```auto
> library(opalr)
Loading required package: httr
> 
> o <- opal.login(username = "administrator", password = "SECRET", url = "https://datashield.research.dhm.mhn.de")
Error in curl::curl_fetch_memory(url, handle = handle) : 
  SSL certificate problem: unable to get local issuer certificate

```

Specifiying the local port, 8443, also still shows the same error - but that should be independent of the Apache reverse proxy configuration anyway:

```auto
> o <- opal.login(username = "administrator", password = "SECRET", url = "https://datashield.research.dhm.mhn.de:8443")
Error in curl::curl_fetch_memory(url, handle = handle) : 
  SSL certificate problem: self signed certificate

```

Where is this “self signed certificate” error coming from? I can’t specify a certificate file location in /etc/opal/opal-config.properties, right?

Best regards,

Sven

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/yannick/32/19_2.png) [@yannick](https://datashield.discourse.group/u/yannick)\
**Post date:** [24 February 2022 12:39 UTC](https://datashield.discourse.group/t/ssl-certificate-check-fails-on-local-opal-login-connection/514/3 "2022-02-24T12:39:13Z")

</div>

Hi,

There is some Opal documentation about [how to setup a reverse proxy](https://opaldoc.obiba.org/en/latest/admin/configuration.html#reverse-proxy-configuration).

Opal is able to serve https connections, BUT in order to have it functional at installation time a default self-signed certificate is generated and applied. Using a self-signed certificate is not secure when attempting to connect through the network, that is why the opal.login function (or any other connection tool) will reject the direct connection to [https://datashield.research.dhm.mhn.de:8443](https://datashield.research.dhm.mhn.de:8443). On the other hand, connecting to [https://localhost:8443](https://localhost:8443) is considered to be ok as it does not go through the wires.

Then, to set up an https service with the outside world, it is recommended to have a reverse proxy (apache or nginx) that handles the SSL communication and then forwards requests to [http://localhost:8080](http://localhost:8080) (or [https://localhost:8443](https://localhost:8443)). It is possible to replace the opal’s self-signed certificate with a valid one (in Administration \> General configuration \> Encryption keys), but using a reverse proxy is simpler and safer: you can control which ciphers suite to use and also see the recommended security headers in the documentation.

Regards  
Yannick

---

<div class="post-metadata">

**Author:** ![duscha](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@duscha](https://datashield.discourse.group/u/duscha)\
**Post date:** [24 February 2022 15:41 UTC](https://datashield.discourse.group/t/ssl-certificate-check-fails-on-local-opal-login-connection/514/4 "2022-02-24T15:41:18Z")

</div>

Hi Yannick,

thank you for the reply.

> [@yannick](#):
>
> There is some Opal documentation about [how to setup a reverse proxy](https://opaldoc.obiba.org/en/latest/admin/configuration.html#reverse-proxy-configuration).

I saw that documentation and followed it. My Apache2 configuration matches it, with the exception that I redirect the proxy to

```auto
ProxyPass / https://datashield.research.dhm.mhn.de:8443/
ProxyPassReverse / https://datashield.research.dhm.mhn.de:8443/

```

So, the problem does not lie in the set up of the SSL-enabled reverse proxy, but in the maintenance locally on the machine.

It turns out, though, that the local connection without SSL/https to port 8080 in R using “opal.login(…)” does work:

o ← opal.login(username = “administrator”, password = “SECRET”, url = “[http://localhost:8080](http://localhost:8080)”)

So, that solves my immediate problem, when trying to import data to the DataSHIELD/Opal server.

NB: Trying to import my proper certificate in Administration → General configuration → Encryption keys fails with an IOException error:

![image](https://global.discourse-cdn.com/free1/uploads/datashield1/original/1X/30644920eca38b7e250e7da935843eeed9df1bbb.png)

Could this be due to some Unix file permissions? Where are the imported keys written to?

But it is not an issue at the moment.

External connection attempts from within R are handled by the Proxy correctly:

```auto
o <- opal.login(username = "administrator", password = "SECRET", url = "https://datashield.research.dhm.mhn.de")

```

Best regards,

Sven
