PFSense 2, OpenVPN roadwarrior scenario with PW + Cert ?

  • What I´m trying to accomplish:

    • Setting up PFSense 2.0 for Road Warrior usage, with a password AND a unique certificate per user for Clients
    • Export windows installer for each user, incl. the complete configuration

    What I did so far:

    • Generated certificates (CA, Server Cert, User Cert)
    • Created OVPN Server using the wizard (in Server Mode: remote access (SSL/TLS with auth) )
    • Exported the user - specific configuration and installed it on a seperate PC

    However, when reviewing the OVPN config file I cannot find any certificates included.

    I´m somehow lost, how can I include certificates as well as a password into my authentication for remote users ?
    Do I need to go with a different Server mode (e.g. Peer2Peer)?

    Any suggestion is appreciated.

  • LAYER 8 Global Moderator

    I use cert to auth, its clearly in the config file

    pkcs12 pfsense-TCP-443.p12
    tls-auth pfsense-TCP-443-tls.key 1

    So your saying your connecting and you don't have a key file in your config directory?

  • Thanks for your reply :) !

    I do have a "whatever-prot-port.key" file as well within my OVPN config, but as far as I see it this is the server key ("TLS authentication") and is not specific to any user.

    I also did revoke a certificate for a user - which should prevent him from logging in - but actually he can still connect perfectly.
    Additionally, any valid user account will do for logging in with the "whatever-prot-port.key" file, though.

    If I understood it correctly the "commonname.crt" files need to be part of the OVPN config in order to make user specific certificates work. This had been working in PFSense 1.x (Option: Authentication method: PKI), but how can this be done in PFSense 2.x ? My expectation would have been the the "client export" tool would export these certificates hence it provides user - specific exports.

    From my actual tests (see above), however, the OVPN config looks completely the same, no matter which user configuration I do export.

    Or am I completely on the wrong track ?  ???

  • LAYER 8 Global Moderator

    So you have

    "When authenticating users, enforce a match between the common name of the client certificate and the username given at login. "

    Checked in the openvpn server setup, and auth method set to SSL/TLS + User Auth?  Screenshot of your openvpn setup might be helpful.

    I can check tmrw from work my setup, I do have username common name on my cert.

    Not sure what is missing here, I will test tmrw from work - I have turned on common name checking, and user auth so lets see if I can get in.  But and I can create a different user and then revoke and such.

    But that cert/key file is per user.  don't you have the

    –pkcs12 file
       Specify a PKCS #12 file containing local private key, local certificate, and root CA certificate. This option can be used instead of --ca, --cert, and --key.

    Option in your config?  Along with tls-auth?

    As to revoking -- did you edit the server setting and set what CRL to use?
    Peer Certificate Revocation List

    Mine is currently set to none with a dropdown to set it.

  • LAYER 8 Global Moderator

    Ok did some testing this morning, created a new user and cert for user testvpn.

    now the name on the p12 downloaded was the same in my case pfsense-TCP-443.p12

    But the certs were clearly different, simple check with hash.

    So I renamed these certs to testvpn.p12 and testvpn.key, modified the config to point to these so I could have multiple configs at the same time.

    So with my old config that did not require username and password I could no longer get in.  So downloaded new config for my johnpoz user and called this config test, and had this entry added auth-user-pass – still pointing to my pfsense-TCP-443.p12 and key

    So now it asked me for username and password and I got in just fine.

    So with my testvpn user I could get in just fine, in the log
    Nov 30 10:55:37 openvpn: user testvpn authenticated
    Nov 30 10:55:35 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=testvpn with depth 0
    Nov 30 10:55:35 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=pfsense-ca with depth 1

    Notice the CN of testvpn

    So then I pointed this config to the other p12, and this failed with
    Nov 30 10:57:03 openvpn: Username does not match certificate common name (testvpn != johnpoz), access denied.
    Nov 30 10:57:02 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=johnpoz with depth 0
    Nov 30 10:57:02 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=pfsense-ca with depth 1

    Notice the CN on that cert is johnpoz

    So changed it back and in again with my testvpn user
    Nov 30 11:01:27 openvpn: user testvpn authenticated
    Nov 30 11:01:25 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=testvpn with depth 0
    Nov 30 11:01:25 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=pfsense-ca with depth 1

    So now I went in and revoked this cert -- see attachment
    And this failed with this
    Nov 30 11:04:38 openvpn[57729]: xx.xx.xx.xx:43850 TLS_ERROR: BIO read tls_read_plaintext error: error:140890B2:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:no certificate returned
    Nov 30 11:04:38 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=testvpn with depth 0
    Nov 30 11:04:38 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=pfsense-ca with depth 1

    So then removed the revoke and work just fine
    Nov 30 11:08:23 openvpn: user testvpn authenticated
    Nov 30 11:08:22 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=testvpn with depth 0
    Nov 30 11:08:22 openvpn: Found certificate /C=us/ST=il/L=schaumburg/O=home/emailAddress=johnpoz@snipped.tld/CN=pfsense-ca with depth 1

    If you want to use revoke, make sure openvpn is set to use the CRL

    If you want to check CN, make sure you check that off.

    But from my testing it is working how you want, each user has their own cert, the .p12 and has to auth with username and password.  And the revoke works as well.

    So your issue is that in the export the config file and certs have the same name on them?  But since these configurations should be on the different machines I don't think that really matters that much.  But guess it should be possible for the maker of the export package to allow for say putting username for the name of the .p12 and .opvn file?

    Minus the common name on the export archive reguardless of username your downloading for it clearly seems to be working exactly how you want it to work.

  • LAYER 8 Global Moderator

    here I added my openvpn server config for reference compared to yours.  Might not be the best looking screencap, had to lower the quality to be under the 250KB limit

    BTW Im currently running
    2.1-DEVELOPMENT (i386)
    built on Fri Nov 25 17:45:38 EST 2011
    FreeBSD 8.1-RELEASE-p6

    With a gitsync as of last night.

  • Thanks a lot for the time you´ve spent, and for the detailed description of your sequence and your configuration - really awesome !

    I compared your configuration with mine, and couldn´t spot any significant difference. However, I did check the "Strict User/CN Matching" off and on again (along with a "save", of course), followed by a reboot. Additionally I did re-export my OVPN configurations and renamed them as per their CN names, just in order to make shure I do not mix anything up and to compare the different behaviours.

    And - magic - it works perfectly now !

    Not shure why it didn´t work on my first trials (and I did a lot of them, starting from scratch over and over again before posting here), it will be hard to identify what the root cause had been hence I did too many changes/steps at once, assumably. However, your post somehow made my day !

    Again, thanks a lot for your help and if I ever make it to Chicago area a couple of beers or whatever you like are on my bill ! :)
    Hopefully your Howto as above might help others as well.

    Thanks ! :)

  • LAYER 8 Global Moderator

    Glad its working for you, wasn't really a lot of time to be honest - you can see from the timestamps on the different logins what about 20 minutes or so.

    Time well spent on working with a settings I had not played with before, I personally don't have any need for multiple certs or being worried that than cn's don't match ;)

    And have not setup password auth either since I have physical control of the device my certs are on – but I can see the desire for these features.  And glad my testing worked somehow got it worked out for you.  I was always sure I could always revoke my cert if lost, but now I have verified that it does work.  In my case though if lost my certs I use - I would prob redo the whole CA portion and gen completely different certs.  But with multiple users revoking clearly a good feature to have working.

    I do agree I think the export tool should name the certs based upon the username being exported vs use of the generic naming scheme - I would think a minor rewrite of the export tool?  Maybe you could write up a post download script you run on the zip before handing it off to the user.

    And should would be up for a beer or two for sure if ever in the chicago area.

Log in to reply