Skip to main content
Build a two-host tunnel to prove the CryptoHub-backed key authenticates a real IKEv2 exchange. The responder authenticates with the key inside the CryptoHub. The initiator uses a file-based key, which keeps the test focused on the HSM side. Substitute your own addresses for these placeholders throughout:
  • RESPONDER_IP — the strongSwan host with the CryptoHub endpoint
  • INITIATOR_IP — the peer host

On the responder: create the initiator’s key and certificate

The initiator’s certificate is issued by the same CryptoHub-resident CA, so both peers trust one root.
Shell
Issue the certificate with the CryptoHub CA key:
Shell
Verify it:
Shell
--verify reports certificate trusted, lifetimes valid.

Transfer the initiator’s files

Copy these three files from the responder to the initiator:
  • peer-key.pem
  • peer-cert.pem
  • strongswanCert.pem
Use scp where available:
Shell
peer-key.pem is an unprotected private key. Transfer it over an encrypted channel, and delete the copy from the responder once the initiator has it:
Shell
If SSH is unavailable on an isolated test network, serve the files briefly over HTTP from the responder with python3 -m http.server 8080 --bind RESPONDER_IP, fetch them with wget, then stop the server with Ctrl+C. Do not use this method for a key you intend to keep.

On the responder: configure the HSM-backed connection

Shell
You already ran these commands in Validate charon can load the HSM-backed private key. They are idempotent; re-run them if you are picking up from a fresh host.
Replace /etc/swanctl/swanctl.conf with a configuration that has both a connection and the token credential:
swanctl.conf
Substitute the two addresses and the PKCS #11 PIN.
This file holds the PIN in cleartext. Keep the mode at 600.
Load it:
Shell
--load-all reports loaded certificate, loaded token, and loaded connection 'responder'. --list-conns lists the responder connection with the net child.

On the initiator: configure the file-based connection

Shell
swanctl.conf
Load it:
Shell
Both hosts list their connection, and the local id on each matches the remote id on the other. A mismatch here is the most common cause of an authentication failure in the next section.