Libreswan Documentation

Logo

Libreswan's Online Documentation

View the Project on GitHub libreswan/libreswan.github.io

Support
FAQ Common Error Messages
History
Implemented Standards
Kernel Support
HOWTO Additional ipsec.conf documentation
AWS Mesh
brendans Road Warrior Setup at Home
Configuration examples
Confuse !?@: github wiki
Enterprise cloud encryption
Entropy matters
EoIP shared ethernet LAN using IPsec
High Availability Fallover VPN in AWS
Host to host VPN
Host to host VPN with PSK
Libreswan as client to a Cisco ASA or VPN3000 server
Microsoft Azure configuration
Migrate from IKEv1 DPD to IKEv2 LIVENESS
Opportunistic IPsec
Opportunistic IPsec using LetsEncrypt
Pluto and DNSSEC
Read status output
Route based VPN
SElinux and Labeled IPsec VPN
Subnet extrusion
Subnet to subnet using NAT
Subnet to subnet VPN
Subnet to subnet VPN with PSK
Unauthenticated Opportunistic IPsec
Using Apache to serve PKCS
Using NSS Hardware Tokens
Using NSS with libreswan
VPN server for remote clients using IKEv2
VPN server for remote clients using IKEv2 split VPN
GSoC 2027 Code Project Ideas DRAFT
Contributor Guidance DRAFT
Completed Projects 2026 RFC 9593 Announcing Supported Authentication Methods in IKEv2
2026 Improve the ACQUIRE to IKE policy lookup
2026 Add HOST TO HOST Support on BSD
2021 RFC 8420 Add EdDSA Signature Authentication Support to IKEv2
2020 Session Resumption
2020 IKEv2 Interop testing with OpenBSD
2020 IKE Intermediate Exchange
2019 Libreswan Opportunistic IPsec using LetsEncrypt
2018 RSA PSS Support in compliance with RFC 7427 and RFC 8247
2018 RFC 7427 Add ECDSA Signature Authentication Support to IKEv2
2018 RFC 5685 Redirect Mechanism
2018 Managing Interface
2017 TCP encapsulation of IKE and IPsec
2017 RFC 7427 Add Signature Authentication Support to IKEv2
2017 Postquantum Preshared Keys
Presentations
IRC
Hacking Documentation
Git, GitHub, and Pull Requests
Merging GitHub Pull Requests
Programming Conventions
Testing Docker
KVM 1. Setup The Host
2. Configure Testing
3. Compile Libreswan
4. Test Libreswan
5. Accessing The Console
6. Maintenance and Internals
Bisecting
Debugging Pluto
Logging In Using SSH
Performance
Running A Custom Kernel
Running A Single Test
Running In The Background
Setup a Web Server
Testing Old Branches
Updating Test Results
Namespace Magic
Namespaces
Topology
Internals 3.14 X509
Benchmarking and Performance testing
Cipher suites and algorithm support
Cloud OE ideas
Compiling with AddressSanitizer
Compliance of RFC 7427 Signature Authentication in IKEv2
Coverity
Cryptographic Acceleration
Developer links strongswan android
Discouraged or forbidden C functions
IKEv2 Child SA
IKEv2 CP and EAP support
Introduction
Libreswan xfrm kernel support
Logging cleanup
New OE
Pluto
Pluto packet processing
Proposed ipsec ca command
Retransmit timings
Road Map
SAref code
Setting up system for debug logging
stf status
Testing 2017 Next Generation
Unbound
Uncrustify
Use Cases and Requirements document for ECC ECDSA support
Use Cases and Requirements document
XFRM Interface Development Notes
XFRM pCPU
XFRM pCPU RSS
Security Crypto boundary and certification
Libreswan and Heartbleed
Libreswan and TunnelCrack
Reporting a Vulnerability
Vulnerabilities
Meetups 2013 Helsinki
2014 San Francisco
2014 Toronto
2018 Toronto
Obsolete HOWTOs IKEv1 XAUTH with FreeOTP and FreeIPA
IKEv1 XAUTH with Google Authenticator One Time Passwords
Route based VPN using VTI
Testing Namespace
VPN server for remote clients using IKEv1 with L2TP
VPN server for remote clients using IKEv1 XAUTH with Certificates
VPN server for remote clients using IKEv1 XAUTH with PSK

Version 3.14 introduces significant changes to pluto’s X509 certificate handling. Prior to 3.14, pluto contained its own functions for certificate and crl parsing and verification. This code is now removed and has been replaced by the NSS library certificate functions.

Database changes

Pluto uses an SQL format NSS database, by default in /etc/ipsec.d. This format allows pluto to pick up changes to the database without requiring a restart. When upgrading libreswan to 3.14, the ‘ipsec checknss’ command run on service startup will attempt to upgrade the existing DBM format database.

When using crlutil or certutil on the upgraded database, you must always prefix the database path with ‘sql:’. For example, to list all certificates:

certutil -L -d sql:/etc/ipsec.d

Running certutil commands without the sql: prefix looks in the directory for different database files that are not read by pluto, so don’t get mixed up! Alternately, you can set the NSS_DEFAULT_DB_TYPE environment variable to ‘sql:’ and use certutil/crlutil as normal.

Certificate changes

Pluto now uses CERT_Certificate structures instead of its internal x509_cert_t structure. The certificates received over the IKE exchange are verified with a call to CERT_PKIXVerifyCert, verifying the certificate down to a root CA that is located in the NSS database. Since the IKE exchange can include intermediate certificates, a temporary import is performed on all certificate payloads received, which places the intermediates into the NSS ephemeral cache. Doing this ensures that the intermediate certs are also verified and used to complete the chain.

The use of NSS certificates now considers the database trust arguments. Before, this did not matter to pluto as the NSS certificates were only converted to the internal pluto certificate when loaded.

The following trust strings should be used:

For example:

 [root@east ~]# certutil -L -d sql:/etc/ipsec.d

 Certificate Nickname                                         Trust Attributes
                                                              SSL,S/MIME,JAR/XPI

 east                                                         u,u,u
 Libreswan test CA for mainca - Libreswan                     CT,,
 north                                                        P,,
 hashsha2                                                     P,,
 west-ec                                                      P,,
 nic                                                          P,,

The ‘CT,,’ trust flags on a CA ensure that the CA is valid for verifying a certificate with the serverAuth/clientAuth EKU extensions. While these are not particularly relevant to the IKE and IPsec standards, the NSS library requires a server or client profile type to be specified during verification. Some clients (Windows) requires client certificates to contain the serverAuth EKU, and due to this NSS API limitation, there will be a failover verification attempt for the serverAuth profile. This way, pluto is able to handle certificates with either serverAuth or clientAuth (or both) set.

For best compatibility with the NSS verification and other clients, at least the digitalSignature and nonRepudiation extensions should be set on end certificates.

CA certificates must have a basicConstraints extension specifying that it is a CA.

CRL changes

Previously, CRLs were placed into /etc/ipsec.d/crls and pluto loaded them internally on startup. The /etc/ipsec.d/crls directory is no longer used in 3.14 and it is required that CRLs are imported into the database. This can be done with:

crlutil -I -i <file> -d sql:/etc/ipsec.d

(TODO: add ipsec importcrl)

When the NSS database contains a valid CRL for a CA used during the IKE exchange, the CRL status is used automatically during certificate verification. Before verifying the certificate there is a check for the issuer’s CRL. The behavior of pluto has not changed in this regard - If a CRL is expired or missing, pluto queues a crl fetch request to be processed during the next check interval (crlcheckinterval). The fetch thread uses curl to retrieve the current CRL at the CA’s CRL URI. The fetched blob is passed to a spawned helper program ‘_import_crl’ that attempts to import the blob as a CRL into the NSS database. Assuming that the fetch resulted in an updated CRL, it is now cached and available for any subsequent exchanges.

The configuration option “strictcrlpolicy” has been renamed to “crl_strict”

In strict mode (crl_strict), a missing or expired CRL results in a rejection. If a peer’s exchange fails while using a good certificate due to the CRL expiring in strict mode, setting a crlcheckinterval that triggers between the peer’s retransmit attempts will allow a fetch to update the CRL and authorize the exchange. The peer will then only notice a delay in connection.

Previously pluto allowed CRLs with an MD5 signature algorithm. These are now rejected by NSS. You must use CRLs with a signature algorithm of at least SHA-1.

OCSP support

Switching to the NSS cert library now gives us OCSP support.

To configure OCSP support, the following ‘config setup’ options are provided:

The following comment from NSS sources explains the failure modes:

/*                                                                      * ocspMode_FailureIsVerificationFailure:                               * This is the classic behaviour of NSS.                                * Any OCSP failure is a verification failure (classic mode, default).  * Without a good response, OCSP networking will be retried each time   * it is required for verifying a cert.                                 *                                                                      * ocspMode_FailureIsNotAVerificationFailure:                           * If we fail to obtain a valid OCSP response, consider the             * cert as good.                                                        * Failed OCSP attempts might get cached and not retried until          * minimumSecondsToNextFetchAttempt.                                    * If we are able to obtain a valid response, the cert                  * will be considered good, if either status is "good"                  * or the cert was not yet revoked at verification time.                *                                                                      * Additional failure modes might be added in the future.               */                                                                   

When enabling OCSP it is recommended to set ocsp_uri and ocsp_trust_name together in order to enable a default responder. Without it, NSS will rely solely on OCSP information contained in the certificates. Similar to the problem of configuring CRL fetches that rely on the IPsec connectivity, configuring an OCSP URI with an address that is only reachable through the IPsec tunnel can be problematic. You should test carefully and adjust the ocsp_timeout option if you are using OCSP responders over an IPsec tunnel or the internet, but for best results you should specify a default responder with an address on the LAN of the ipsec host.

An OCSP responder certificate can be a CA, or a seperate certificate issued just for the responder’s OCSP service, and it must be pre-loaded into the NSS database before starting pluto. The OCSP responder certificate should have the OCSP Responder Certificate EKU extension, and an OCSP authInfo ext. with the URI of the OCSP responder.

For example, the test harness has a certificate ‘nic’ used for OCSP. Its extensions are:

        Signed Extensions:             Name: Certificate Basic Constraints             Data: Is not a CA.

            Name: Certificate Key Usage             Usages: Digital Signature                     Non-Repudiation                     Certificate Signing                     CRL Signing 

            Name: Extended Key Usage                 TLS Web Server Authentication Certificate                 TLS Web Client Authentication Certificate                 Code Signing Certificate                 OCSP Responder Certificate

            Name: Authority Information Access             Method: PKIX Online Certificate Status Protocol             Location:                  URI: "http://nic.testing.libreswan.org:2560

            Name: CRL Distribution Points             Distribution point:                 URI: "http://nic.testing.libreswan.org/revoked.crl"

The CRL Signing/Certificate Signing KU extensions and Code Signing EKU may also be required. This text should be updated when this is confirmed.

OCSP requests are HTTP GET type through the NSS library. The NSS state maintains an OCSP cache that can be cleared for a running instance of pluto with ‘ipsec auto –purgeocsp’.

Test coverage

WIP..

Test list:

1. Requires ocspd installed on nic (available in fedora repo)

2. pyOpenSSL on testing host system needs a patch to support creating SHA-1 signed CRL. https://nohats.ca/ftp/pyOpenSSL/pyOpenSSL-0.14-4.fc21.noarch.rpm