Documentation

pfSense: IPsec VPN with Okivo

Documentation
On this page

Plan feature RADIUS/VPN, from the Team plan on.

With the package pfSense-pkg-okivo users approve every IPsec VPN sign-in on a pfSense by push in the Okivo app. You don't need a separate RADIUS server for this.

The package brings the small service okivod. It runs on the firewall, answers RADIUS only on 127.0.0.1 and appears in pfSense as the authentication server “Okivo”. Per sign-in it does two steps:

  1. It checks the password.
  2. It triggers the push through the Okivo plugin in your Keycloak.
Text
Client ──IKE_AUTH (EAP or Xauth)──> pfSense/strongSwan ──RADIUS (127.0.0.1)──> okivod
                                                                                │ 1. check password
                                                                                │ 2. request push
                                                                                ▼
                                                         Keycloak + Okivo plugin ──> Okivo app

The settings form under VPN → Okivo is in English like the pfSense GUI. The status page and the messages follow the pfSense language (System → General Setup → Language): German or English.

Requirements

  • pfSense on amd64 or on a Netgate device with ARM (arm64).
  • Keycloak with the Okivo plugin, realm set up (Install the Keycloak plugin); the plan includes RADIUS/VPN.
  • The pfSense reaches Keycloak via HTTPS.
  • The realm's inbound API key. Without a separate key that's the Tenant API Key from the portal; how to set a separate one is described in Inbound API key.
  • The users have set up a device in the Okivo app.

Which password source for which clients

Passwords come from one of four sources. That determines which clients work without extra software:

Why the built-in clients only work with EAP users: they can only do EAP-MSCHAPv2 (or certificates). For MSCHAPv2 the verifier needs the password in plain text or as an NT hash, and only the pfSense EAP users have that. Keycloak, LDAP and the User Manager store passwords in a way that doesn't allow MSCHAPv2 checks.

Active Directory with built-in clients: then the way is a separate RADIUS server with Okivo, see RADIUS with FreeRADIUS.

Setup

  1. Install the package. In the pfSense shell (Diagnostics → Command Prompt or SSH), first check which package fits, then install it:

    Shell
    pkg config abi    # e.g. FreeBSD:16:amd64 → package …-fbsd16-amd64.pkg
    pkg add -f https://okivo.app/releases/pfsense/<version>/pfSense-pkg-okivo-<version>-fbsd16-amd64.pkg
    

    There is one package per FreeBSD version: fbsd15 for pfSense 2.8, fbsd16 for pfSense 2.9. pkg rejects the wrong one with "wrong architecture". Netgate devices with ARM need …-arm64.pkg. The packages are public under https://okivo.app/releases/pfsense/<version>/, without sign-in. In the file name the version has a dot instead of - (pre-release 1.0.0-rc.1 → pfSense-pkg-okivo-1.0.0.rc.1-fbsd16-amd64.pkg in the folder 1.0.0-rc.1/). The package is not yet in Netgate's package catalogue.

  2. VPN → Okivo:

    • Tick Enable.
    • Enter the Keycloak URL (e.g. https://id.example.com), Realm and API key (the realm's inbound API key).
    • Name in the push: appears in the app as “VPN · name”. Empty = hostname of the firewall.
    • Choose the Password source and fill in its fields (LDAP: LDAP server, Bind DN, Base DN, User filter; Keycloak: see below).
    • For EAP-TTLS choose the Certificate for EAP-TTLS, ideally the same server certificate as for IKE.
    • Timeout (seconds): how long okivod waits for the approval, at most 65. Okivo itself waits 60 seconds.
    • Save. The package then creates the authentication server “Okivo” and starts okivod.
  3. VPN → Okivo → Status & Test → “Test”:

    • Without a user the test checks Keycloak, API key and plan.
    • With a user it also checks the password and sends a push to that user's phone.
  4. VPN → IPsec → Mobile Clients:

    • User Authentication: “Okivo”.
    • RADIUS retransmit: timeout 10, attempts 7, base 1. With this pfSense waits a good 70 seconds for the approval. With the defaults (2 s, 4 attempts, base 1.4) pfSense gives up after about 15 seconds; that's too short for an approval on the phone.
  5. Phase 1:

    • IKEv2: authentication method EAP-RADIUS, “My Certificate” = server certificate.
    • IKEv1: Mutual PSK + Xauth.
    • Not EAP-MSCHAPv2. With it, strongSwan checks the password itself against the EAP users and never asks okivod: the sign-in works, but without a push. Also under Mobile Clients choose only Okivo for “User Authentication”, not “Local Database” as well.
  6. Users:

    • With the source “pfSense EAP users”, create one entry of type EAP per user under VPN → IPsec → Pre-Shared Keys.
    • The username must match the user in Keycloak. For differing names, VPN → Okivo offers:
      • Strip domain: “CORP\anna” and “anna@corp.example” become “anna” in Okivo.
      • Append suffix: appended to the name, e.g. @corp.example.
      • Lowercase: convert usernames to lowercase for Okivo.

Source Keycloak

okivod checks the password with the password grant of a dedicated client and then triggers the push itself. The client must therefore not have a push step of its own:

  1. Create the client okivo-vpn, enable only Direct Access Grants.
  2. Create an authentication flow “VPN – password only”: a copy of “direct grant” with Username Validation and Password, without OTP and without Push MFA.
  3. In the client under Advanced → Authentication flow overrides, choose this flow for Direct Grant Flow.
  4. In VPN → Okivo: Password source “Keycloak”, Keycloak client okivo-vpn and – if the client is confidential – the Client secret.

How a sign-in works

  • Wrong password: no push is sent; the sign-in is rejected immediately.
  • Correct password: okivod waits up to 60 seconds for approval or block in the app. The app shows “VPN · <name of the firewall>” with the client's public IP.
  • Repeated requests: pfSense repeats the RADIUS request while the response is pending. okivod answers repetitions from the running process; exactly one push is sent.
  • EAP-TTLS: Windows sends the password inside the tunnel as PAP. The strongSwan app sends an inner EAP; okivod then asks for the password via EAP-GTC.
  • VPN sign-ins have no number matching and no code: the user just approves.

pfSense updates

After a pfSense update, check whether the package is still installed; otherwise install it again with pkg add. The settings remain in the pfSense configuration.

Troubleshooting

Other places to look:

  • Status → System Logs → IPsec
  • Status → System Logs → General (entries from okivod)
  • VPN → Okivo → Status & Test