OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 19.1 Legacy Series »
  • [SOLVED] OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« previous next »
  • Print
Pages: [1]

Author Topic: [SOLVED] OPNsense 19.1: OpenVPN and intermediate CA doesn't work  (Read 12320 times)

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
[SOLVED] OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« on: February 12, 2019, 09:03:01 pm »
Hi!

I have created the following setup:

1. Created "Root CA" using the OPNsense trust manager
2. Created "Server CA" as intermediate of Root CA using the OPNsense trust manager
3. Created "VPN CA" as intermediate of Root CA using the OPNsense trust manager
4. Generated a server certificate "Server Cert" signed by "Server CA" using the OPNsense trust manager
5. Created an OpenVPN server using the wizard with the following settings:
5.1. Server Certificate: "Server Cert"
5.2. Peer Certificate Authority: "VPN CA"
5.3. Certificate Depth: "Do Not Check"
5.4. Strict User/CN Matching: (x)
6. Created a user "vpnuser" with a client certificate issued by "VPN CA"
7. Created an OpenVPN client export for the "vpnuser"

Then, I when I try to connect from the client, the server complains that it cannot verify an issuer certificate:

Code: [Select]
Feb 12 20:52:41 openvpn[16478]: CLIENT_IP:20435 TLS Error: TLS handshake failed
Feb 12 20:52:41 openvpn[16478]: CLIENT_IP:20435 TLS Error: TLS object -> incoming plaintext read error
Feb 12 20:52:41 openvpn[16478]: CLIENT_IP:20435 TLS_ERROR: BIO read tls_read_plaintext error
Feb 12 20:52:41 openvpn[16478]: CLIENT_IP:20435 OpenSSL: error:14089086:SSL routines:ssl3_get_client_certificate:certificate verify failed
Feb 12 20:52:41 openvpn[16478]: CLIENT_IP:20435 VERIFY ERROR: depth=1, error=unable to get issuer certificate: C=xx, ST=xxx, L=xxx, O=xxx, emailAddress=xxx, CN=VPN CA

The strange workaround, according to two other existing threads in this forum (https://forum.opnsense.org/index.php?topic=9888.0 and https://forum.opnsense.org/index.php?topic=4830.0), is to manually append the "Root CA" certificate data at the end of the "VPN CA" certificate data in the OPNsense trust manager.

That should not be required! OPNsense should configure OpenVPN to use the entire local CA certificate chain.

Cheers,
Wolfram
« Last Edit: February 15, 2019, 04:15:57 pm by franco »
Logged

newsense

  • Hero Member
  • *****
  • Posts: 1038
  • Karma: 77
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #1 on: February 13, 2019, 02:12:07 am »
You actually need the RootCA imported on the client - if Windows then certmgr.msc - Machine - Personal store
Logged

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #2 on: February 13, 2019, 06:07:20 am »
I'm talking about *server* log/error messages, not *client* ones.
The server complains that it cannot verify the client certificate.
Logged

newsense

  • Hero Member
  • *****
  • Posts: 1038
  • Karma: 77
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #3 on: February 13, 2019, 06:37:14 am »
Sadly I don't have two running instances to test, but I'd really appreciate if you could show me the error logs after you add the root CA as I mentioned earlier.
Logged

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #4 on: February 13, 2019, 07:03:19 am »
It's unchanged, obviously.
Logged

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #5 on: February 13, 2019, 07:13:43 am »
The openvpn server process is using a single CA (namely the "VPN CA"), not the full local CA chain:
Code: [Select]
[root@opnsense ~]# ps auxwwf | grep [o]penvpn
root    28509   0.0  0.2 1062000  7576  -  Ss   07:04       0:00.09 /usr/local/sbin/openvpn --config /var/etc/openvpn/server1.conf
[root@opnsense ~]# grep '^ca' /var/etc/openvpn/server1.conf
ca /var/etc/openvpn/server1.ca
[root@opnsense ~]# grep 'BEGIN CERTIFICATE' /var/etc/openvpn/server1.ca | wc -l
       2
[root@opnsense ~]# /usr/local/bin/openssl x509 -in /var/etc/openvpn/server1.ca -noout -subject
subject= /C=xxx/ST=xxx/L=xxx/O=xxx/emailAddress=xxx/CN=VPN CA
[root@opnsense ~]#

I consider this a (very annoying) bug in OPNsense, as the OpenVPN configuration logic should be intelligent enough to resolve the full local CA chain.
« Last Edit: February 13, 2019, 10:20:32 am by wschlich »
Logged

newsense

  • Hero Member
  • *****
  • Posts: 1038
  • Karma: 77
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #6 on: February 13, 2019, 07:23:02 am »
In VPN-Servers what's the certificate depth ?
Logged

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #7 on: February 13, 2019, 08:33:29 am »
See my initial posting :)
Logged

newsense

  • Hero Member
  • *****
  • Posts: 1038
  • Karma: 77
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #8 on: February 13, 2019, 08:49:35 am »
Well that's why it doesn't make any sense, you have Do Not Check however the workarounds suggesting to add the root CA to the intermediary is aking to option Two - which I would have chosen for this setup...

Otherwise with DNC it surely looks like you're attempting to establish a connection using digital certificates by explicitly rejecting any validation of said certificates o_0
Logged

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #9 on: February 13, 2019, 10:19:00 am »
@newsense You don't seem to understand the basics here and I don't have the time and energy to explain (sorry about that). I'd recommend to read the documentation about the Certificate Depth option (or the OpenVPN --tls-verify option).
« Last Edit: February 17, 2019, 01:15:23 pm by wschlich »
Logged

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #10 on: February 13, 2019, 10:19:43 am »
Seems there was already a github issue for this problem which should be reopened: https://github.com/opnsense/core/issues/1487
Logged

wschlich

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
    • View Profile
Re: OPNsense 19.1: OpenVPN and intermediate CA doesn't work
« Reply #11 on: February 13, 2019, 01:59:43 pm »
Whoohoo, fixed by AdSchellevis in https://github.com/opnsense/core/commit/67f49486708770633ca615ee41f53439e0a962ce and scheduled for 19.1.2 by franco :D
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 19.1 Legacy Series »
  • [SOLVED] OPNsense 19.1: OpenVPN and intermediate CA doesn't work
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2