]> git.ipfire.org Git - people/ms/strongswan.git/blob - README
d40d887a3519657b9a048954f95d39071604e079
[people/ms/strongswan.git] / README
1 ----------------------------
2 strongSwan - Configuration
3 ----------------------------
4
5
6 Contents
7 --------
8
9 1. Overview
10 2. Quickstart
11 2.1 Site-to-Site case
12 2.2 Host-to-Host case
13 2.3 Four Tunnel case
14 2.4 Four Tunnel case the elegant way with source routing
15 2.5 Roadwarrior case
16 2.6 Roadwarrior case with virtual IP
17 3. Generating X.509 certificates and CRLs with OpenSSL
18 3.1 Generating a CA certificate
19 3.2 Generating a host or user certificate
20 3.3 Generating a CRL
21 3.4 Revoking a certificate
22 4. Configuring the connections - ipsec.conf
23 4.1 Configuring my side
24 4.2 Multiple certificates
25 4.3 Configuring the peer side using CA certificates
26 4.4 Handling Virtual IPs and wildcard subnets
27 4.5 Protocol and port selectors
28 4.6 IPsec policies based on wildcards
29 4.7 IPsec policies based on CA certificates
30 4.8 Sending certificate requests
31 4.9 IPsec policies based on group attributes
32 5. Configuring certificates and CRLs
33 5.1 Installing CA certificates
34 5.2 Installing optional Certificate Revocation Lists (CRLs)
35 5.3 Dynamic update of certificates and CRLs
36 5.4 Local caching of CRLs
37 5.5 Online Certificate Status Protocol (OCSP)
38 5.6 CRL policy
39 5.7 Configuring the peer side using locally stored certificates
40 6. Configuring the private keys - ipsec.secrets
41 6.1 Loading private key files in PKCS#1 format
42 6.2 Entering passphrases interactively
43 6.3 Multiple private keys
44 7. Configuring CA properties - ipsec.conf
45 8. Smartcard support
46 8.1 Configuring a smartcard-based connection
47 8.2 Entering the PIN code
48 8.3 PIN-pad equipped smartcard readers
49 8.4 Configuring a smartcard using pkcs15-init
50 8.5 PKCS#1 proxy functions
51 9. Configuring the clients
52 9.1 strongSwan
53 9.2 PGPnet
54 9.3 Safenet/Soft-Remote
55 9.4 SSH Sentinel
56 9.5 Windows 2000/XP
57 10. Monitoring functions
58 11. Firewall support functions
59 11.1 Environment variables in the updown script
60 11.2 Automatic insertion and deletion of iptables firewall rules (NEW)
61 11.3 Sample Linux 2.6 _updown_espmark script for iptables < 1.3.5
62 12. Authentication with raw RSA public keys
63 13. Authentication with OpenPGP certificates
64 13.1 OpenPGP certificates
65 13.2 OpenPGP private keys
66 13.3 Monitoring functions
67 13.4 Suppression of certificate request messages
68 14. Additional features
69 14.1 Authentication and encryption algorithms
70 14.2 NAT traversal
71 14.3 Dead peer detection
72 14.4 IKE Mode Config
73 15. Copyright statement and acknowledgements
74
75
76 1. Overview
77 --------
78
79 strongSwan is an OpenSource IPsec solution for the Linux operating system
80 and currently supports the following features:
81
82 * runs both on Linux 2.4 (KLIPS) and Linux 2.6 (native IPsec) kernels.
83
84 * strong 3DES, AES, Serpent, Twofish, or Blowfish encryption.
85
86 * Authentication based on X.509 certificates or preshared secrets.
87
88 * IPsec policies based on wildcards or intermediate CAs.
89
90 * Powerful and flexible IPsec policies based on group attributes.
91
92 * Retrieval of Certificate Revocation Lists (CRLs) via HTTP or LDAP.
93
94 * Local caching of fetched CRLs
95
96 * Full support of the Online Certificate Status Protocol (OCSP, RFC 2560).
97
98 * CA management functions including OCSP and CRL URIs and default LDAP server.
99
100 * Optional storage of RSA private keys on smartcards or USB crypto tokens
101
102 * Standardized PKCS#11 interface with optional proxy functions serving
103 external applications (disc encryption, etc.).
104
105 * NAT-Traversal (RFC 3947)
106
107 * Support of Virtual IPs via static configuratin and IKE Mode Config
108
109 * Support of Delete SA and informational Notification messages.
110
111 * Dead Peer Detection (DPD, RFC 3706)
112
113 Compatibility has successfully been tested with peers running the following
114 IPsec clients:
115
116 FreeS/WAN, Openswan, SafeNet/SoftRemote, NCP Secure Entry Client,
117 SonicWALL Global VPN Client, The GreenBow, Microsoft Windows 2000/XP, etc.
118
119 Furthermore, interoperability with the following VPN gateways
120 has been demonstrated during the IPsec 2001 Conference in Paris:
121
122 Cisco IOS Routers, Cisco PIX firewall, Cisco VPN3000,
123 Nortel Contivity VPN Switch, NetScreen (FreeS/WAN as responder only),
124 OpenBSD with isakmpd, Netasq, Netcelo, and 6WIND.
125
126 Potentially any IPsec implementation with X.509 certificate support can
127 be made to cooperate with strongSwan. The latest addition has been the successful
128 interoperability with the Check Point VPN-1 NG gateway.
129
130
131 2. Quickstart
132 ----------
133
134 In the following examples we assume for reasons of clarity that left designates
135 the local host and that right is the remote host. Certificates for users, hosts
136 and gateways are issued by a ficticious strongSwan CA. How to generate private keys
137 and certificates using OpenSSL will be explained in section 3. The CA certificate
138 "strongswanCert.pem" must be present on all VPN end points in order to be able to
139 authenticate the peers.
140
141
142 2.1 Site-to-site case
143 -----------------
144
145 In this scenario two security gateways moon and sun will connect the
146 two subnets moon-net and sun-net with each other through a VPN tunnel
147 set up between the two gateways:
148
149 10.1.0.0/16 -- | 192.168.0.1 | === | 192.168.0.2 | -- 10.2.0.0/16
150 moon-net moon sun sun-net
151
152 Configuration on gateway moon:
153
154 /etc/ipsec.d/cacerts/strongswanCert.pem
155
156 /etc/ipsec.d/certs/moonCert.pem
157
158 /etc/ipsec.secrets:
159
160 : RSA moonKey.pem "<optional passphrase>"
161
162 /etc/ipsec.conf:
163
164 conn net-net
165 left=%defaultroute
166 leftsubnet=10.1.0.0/16
167 leftcert=moonCert.pem
168 right=192.168.0.2
169 rightsubnet=10.2.0.0/16
170 rightid="C=CH, O=Linux strongSwan, CN=sun.strongswan.org"
171 auto=start
172
173 Configuration on gateway sun:
174
175 /etc/ipsec.d/cacerts/strongswanCert.pem
176
177 /etc/ipsec.d/certs/sunCert.pem
178
179 /etc/ipsec.secrets:
180
181 : RSA sunKey.pem "<optional passphrase>"
182
183 /etc/ipsec.conf:
184
185 conn net-net
186 left=%defaultroute
187 leftsubnet=10.2.0.0/16
188 leftcert=sunCert.pem
189 right=192.168.0.1
190 rightsubnet=10.1.0.0/16
191 rightid="C=CH, O=Linux strongSwan, CN=moon.strongswan.org"
192 auto=start
193
194
195 2.2 Host-to-host case
196 -----------------
197
198 This is a setup between two single hosts which don't have a subnet behind
199 them. Although IPsec transport mode would be sufficient for host-to-host
200 connections we will use the default IPsec tunnel mode.
201
202 | 192.168.0.1 | === | 192.168.0.2 |
203 moon sun
204
205 Configuration on host moon:
206
207 /etc/ipsec.d/cacerts/strongswanCert.pem
208
209 /etc/ipsec.d/certs/moonCert.pem
210
211 /etc/ipsec.secrets:
212
213 : RSA moonKey.pem "<optional passphrase>"
214
215 /etc/ipsec.conf:
216
217 conn host-host
218 left=%defaultroute
219 leftcert=moonCert.pem
220 right=192.168.0.2
221 rightid="C=CH, O=Linux strongSwan, CN=sun.strongswan.org"
222 auto=start
223
224 Configuration on host sun:
225
226 /etc/ipsec.d/cacerts/strongswanCert.pem
227
228 /etc/ipsec.d/certs/sunCert.pem
229
230 /etc/ipsec.secrets:
231
232 : RSA sunKey.pem "<optional passphrase>"
233
234 /etc/ipsec.conf:
235
236 conn host-host
237 left=%defaultroute
238 leftcert=sunCert.pem
239 right=192.168.0.1
240 rightid="C=CH, O=Linux strongSwan, CN=moon.strongswan.org"
241 auto=start
242
243
244 2.3 Four Tunnel case
245 ----------------
246
247 In a site-to-site setup a system administrator logged into the local gateway
248 often would like to access the peer gateway or a server in the subnet behind
249 the peer gateway over a secure IPsec tunnel.Since IP packets leaving a gateway
250 via the outer network interface carry the IP address of this NIC, four IPsec
251 Security Associations (SAs) must be set up to achieve full connectivity. The
252 example below shows how this can be done without much additional typing work ,
253 using the "also" macro which includes connection definitions defined farther
254 down in the ipsec.conf file.
255
256 10.1.0.0/16 -- | 192.168.0.1 | === | 192.168.0.2 | -- 10.2.0.0/16
257 moon-net moon sun sun-net
258
259 Configuration on gateway moon:
260
261 /etc/ipsec.d/cacerts/strongswanCert.pem
262
263 /etc/ipsec.d/certs/moonCert.pem
264
265 /etc/ipsec.secrets:
266
267 : RSA moonKey.pem "<optional passphrase>"
268
269 /etc/ipsec.conf:
270
271 conn net-net
272 leftsubnet=10.1.0.0/16
273 rightsubnet=10.2.0.0/16
274 also host-host
275
276 conn net-host
277 leftsubnet=10.1.0.0/16
278 also host-host
279
280 conn host-net
281 rightsubnet=10.2.0.0/16
282 also host-host
283
284 conn host-host
285 left=%defaultroute
286 leftcert=moonCert.pem
287 right=192.168.0.2
288 rightid="C=CH, O=Linux strongSwan, CN=sun.strongswan.org"
289 auto=start
290
291 Configuration on gateway sun:
292
293 /etc/ipsec.d/cacerts/strongswanCert.pem
294
295 /etc/ipsec.d/certs/sunCert.pem
296
297 /etc/ipsec.secrets:
298
299 : RSA sunKey.pem "<optional passphrase>"
300
301 /etc/ipsec.conf:
302
303 conn net-net
304 leftsubnet=10.2.0.0/16
305 rightsubnet=10.1.0.0/16
306 also=host-host
307
308 conn net-host
309 leftsubnet=10.2.0.0/16
310 also=host-host
311
312 conn host-net
313 rightsubnet=10.1.0.0/16
314 also=host-host
315
316 conn host-host
317 left=%defaultroute
318 leftcert=sunCert.pem
319 right=192.168.0.1
320 rightid="C=CH, O=Linux strongSwan, CN=moon.strongswan.org"
321 auto=start
322
323
324 2.4 The four tunnel case the elegant way with source routing
325 --------------------------------------------------------
326
327 As you certainly agree, the full four tunnel case described in the previous
328 section becomes quite complex. If we could force the source address of the
329 IP packets leaving the gateway through the outer interface to take on the
330 IP address of the inner interface then we could use the single subnet-to-subnet
331 tunnel from section 2.1. Such a setup becomes possible if we use the
332 source routing capabilites of the ip route command that is already used
333 by strongSwan's updown scripts.
334
335 10.1.0.0/16 -- | 192.168.0.1 | === | 192.168.0.2 | -- 10.2.0.0/16
336 moon-net moon sun sun-net
337
338 If we assume that the inner IP address of gateway moon is 10.1.0.1
339 and the inner IP address of gateway sun is 10.2.0.1 then the
340 insertion of the parameter
341
342 leftsourceip=10.1.0.1
343
344 in the connection definition of moon and
345
346 leftsourceip=10.2.0.1
347
348 on sun, respectively, will install source routing on both gateways.
349 As a result the command
350
351 ping 10.2.0.1
352
353 executed on moon will leave the gateway with a source address of
354 10.1.0.1 and will therefore take the net-net IPsec tunnel.
355
356 Configuration on gateway moon:
357
358 /etc/ipsec.d/cacerts/strongswanCert.pem
359
360 /etc/ipsec.d/certs/moonCert.pem
361
362 /etc/ipsec.secrets:
363
364 : RSA moonKey.pem "<optional passphrase>"
365
366 /etc/ipsec.conf:
367
368 conn net-net
369 left=%defaultroute
370 leftsourceip=10.1.0.1
371 leftsubnet=10.1.0.0/16
372 leftcert=moonCert.pem
373 right=192.168.0.2
374 rightsubnet=10.2.0.0/16
375 rightid="C=CH, O=Linux strongSwan, CN=sun.strongswan.org"
376 auto=start
377
378 Configuration on gateway sun:
379
380 /etc/ipsec.d/cacerts/strongswanCert.pem
381
382 /etc/ipsec.d/certs/sunCert.pem
383
384 /etc/ipsec.secrets:
385
386 : RSA sunKey.pem "<optional passphrase>"
387
388 /etc/ipsec.conf:
389
390 conn net-net
391 left=%defaultroute
392 leftsubnet=10.2.0.0/16
393 leftsourceip=10.2.0.1
394 leftcert=sunCert.pem
395 right=192.168.0.1
396 rightsubnet=10.1.0.0/16
397 rightid="C=CH, O=Linux strongSwan, CN=moon.strongswan.org"
398 auto=start
399
400
401 2.5 Roadwarrior case
402 ----------------
403
404 This is a very common case where a strongSwan gateway serves an arbitrary number
405 of remote VPN clients usually having dynamic IP addresses.
406
407 10.1.0.0/16 -- | 192.168.0.1 | === | x.x.x.x |
408 moon-net moon carol
409
410 Configuration on gateway moon:
411
412 /etc/ipsec.d/cacerts/strongswanCert.pem
413
414 /etc/ipsec.d/certs/moonCert.pem
415
416 /etc/ipsec.secrets:
417
418 : RSA moonKey.pem "<optional passphrase>"
419
420 /etc/ipsec.conf:
421
422 conn rw
423 left=%defaultroute
424 leftsubnet=10.1.0.0/16
425 leftcert=moonCert.pem
426 right=%any
427 auto=add
428
429 Configuration on roadwarrior carol:
430
431 /etc/ipsec.d/cacerts/strongswanCert.pem
432
433 /etc/ipsec.d/certs/carolCert.pem
434
435 /etc/ipsec.secrets:
436
437 : RSA carolKey.pem "<optional passphrase>"
438
439 /etc/ipsec.conf:
440
441 conn home
442 left=%defaultroute
443 leftcert=carolCert.pem
444 right=192.168.0.1
445 rightsubnet=10.1.0.0/16
446 rightid="C=CH, O=Linux strongSwan, CN=moon.strongswan.org"
447 auto=start
448
449
450 2.6 Roadwarrior case with virtual IP
451 --------------------------------
452
453 Roadwarriors usually have dynamic IP addresses assigned by the ISP they are
454 currently attached to. In order to simplify the routing from moon-net back
455 to the remote access client carol it would be desirable if the roadwarrior had
456 an inner IP address chosen from a pre-assigned pool.
457
458 10.1.0.0/16 -- | 192.168.0.1 | === | x.x.x.x | -- 10.3.0.1
459 moon-net moon carol virtual IP
460
461 This virtual IP address can be assigned to a strongSwan roadwarrior by adding
462 the parameter
463
464 leftsourceip=10.3.0.1
465
466 to the roadwarrior's ipsec.conf. Of course the virtual IP of each roadwarrior
467 must be distinct. In our example it is chosen from the address pool
468
469 rightsubnetwithin=10.3.0.0/16
470
471 which can be added to the gateway's ipsec.conf so that a single connection
472 definition can handle multiple roadwarriors.
473
474 Configuration on gateway moon:
475
476 /etc/ipsec.d/cacerts/strongswanCert.pem
477
478 /etc/ipsec.d/certs/moonCert.pem
479
480 /etc/ipsec.secrets:
481
482 : RSA moonKey.pem "<optional passphrase>"
483
484 /etc/ipsec.conf:
485
486 conn rw
487 left=%defaultroute
488 leftsubnet=10.1.0.0/16
489 leftcert=moonCert.pem
490 right=%any
491 rightsubnetwithin=10.3.0.0/16
492 auto=add
493
494 Configuration on roadwarrior carol:
495
496 /etc/ipsec.d/cacerts/strongswanCert.pem
497
498 /etc/ipsec.d/certs/carolCert.pem
499
500 /etc/ipsec.secrets:
501
502 : RSA carolKey.pem "<optional passphrase>"
503
504 /etc/ipsec.conf:
505
506 conn home
507 left=%defaultroute
508 leftsourceip=10.3.0.1
509 leftcert=carolCert.pem
510 right=192.168.0.1
511 rightsubnet=10.1.0.0/16
512 rightid="C=CH, O=Linux strongSwan, CN=moon.strongswan.org"
513 auto=start
514
515
516 3. Generating certificates and CRLs with OpenSSL
517 ---------------------------------------------
518
519 This section is not a full-blown tutorial on how to use OpenSSL. It just lists
520 a few points that are relevant if you want to generate your own certificates
521 and CRLs for use with strongSwan.
522
523
524 3.1 Generating a CA certificate
525 ---------------------------
526
527 The OpenSSL statement
528
529 openssl req -x509 -days 1460 -newkey rsa:2048 \
530 -keyout strongswanKey.pem -out strongswanCert.pem
531
532 creates a 2048 bit RSA private key strongswanKey.pem and a self-signed CA
533 certificate strongswanCert.pem with a validity of 4 years (1460 days).
534
535 openssl x509 -in cert.pem -noout -text
536
537 lists the properties of a X.509 certificate cert.pem. It allows you to verify
538 whether the configuration defaults in openssl.cnf have been inserted correctly.
539
540 If you prefer the CA certificate to be in binary DER format then the following
541 command achieves this transformation:
542
543 openssl x509 -in strongswanCert.pem -outform DER -out strongswanCert.der
544
545 The directory /etc/ipsec.d/cacerts contains all required CA certificates either
546 in binary DER or in base64 PEM format. Irrespective of the file suffix, Pluto
547 "automagically" determines the correct format.
548
549
550 3.2 Generating a host or user certificate
551 -------------------------------------
552
553 The OpenSSL statement
554
555 openssl req -newkey rsa:1024 -keyout hostKey.pem \
556 -out hostReq.pem
557
558 generates a 1024 bit RSA private key hostKey.pem and a certificate request
559 hostReq.pem which has to be signed by the CA.
560
561 If you want to add a subjectAltName field to the host certificate you must edit
562 the OpenSSL configuration file openssl.cnf and add the following line in the
563 [ usr_cert ] section:
564
565 subjectAltName=DNS:moon.strongswan.org
566
567 if you want to identify the host by its Fully Qualified Domain Name (FQDN ), or
568
569 subjectAltName=IP:192.168.0.1
570
571 if you want the ID to be of type IPV4_ADDR. Of course you could include both
572 ID types with
573
574 subjectAltName=DNS:moon.strongswan.org,IP:192.168.0.1
575
576 but the use of an IP address for the identification of a host should be
577 discouraged anyway.
578
579 For user certificates the appropriate ID type is USER_FQDN which can be
580 specified as
581
582 subjectAltName=email:carol@strongswan.org
583
584 or if the user's e-mail address is part of the subject's distinguished name
585
586 subjectAltName=email:copy
587
588 Now the certificate request can be signed by the CA with the command
589
590 openssl ca -in hostReq.pem -days 730 -out hostCert.pem -notext
591
592 If you omit the -days option then the default_days value (365 days) specified
593 in openssl.cnf is used. The -notext option avoids that a human readable
594 listing of the certificate is prepended to the base64 encoded certificate
595 body.
596
597 If you want to use the dynamic CRL fetching feature described in section 4.7
598 then you may include one or several crlDistributionPoints in your end
599 certificates. This can be done in the [ usr_cert ] section of the openssl.cnf
600 configuration file:
601
602 crlDistributionPoints= @crl_dp
603
604 [ crl_dp ]
605
606 URI.1="http://crl.strongswan.org/strongswan.crl"
607 URI.2="ldap://ldap.strongswan.org/cn=strongSwan Root CA, o=Linux strongSwan
608 , c=CH?certificateRevocationList"
609
610 If you have only a single http distribution point then the short form
611
612 crlDistributionPoints="URI:http://crl.strongswan.org/strongswan.crl"
613
614 also works. Due to a known bug in OpenSSL this notation fails with ldap URIs.
615
616 Usually a Windows-based VPN client needs its private key, its host or
617 user certificate, and the CA certificate. The most convenient way to load
618 this information is to put everything into a PKCS#12 file:
619
620 openssl pkcs12 -export -inkey carolKey.pem \
621 -in carolCert.pem -name "carol" \
622 -certfile strongswanCert.pem -caname "strongSwan Root CA" \
623 -out carolCert.p12
624
625
626 3.3 Generating a CRL
627 ----------------
628
629 An empty CRL that is signed by the CA can be generated with the command
630
631 openssl ca -gencrl -crldays 15 -out crl.pem
632
633 If you omit the -crldays option then the default_crl_days value (30 days)
634 specified in openssl.cnf is used.
635
636 If you prefer the CRL to be in binary DER format then this conversion
637 can be achieved with
638
639 openssl crl -in crl.pem -outform DER -out cert.crl
640
641 The directory /etc/ipsec.d/crls contains all CRLs either in binary DER
642 or in base64 PEM format. Irrespective of the file suffix, Pluto
643 "automagically" determines the correct format.
644
645
646 3.4 Revoking a certificate
647 ----------------------
648
649 A specific host certificate stored in the file host.pem is revoked with the
650 command
651
652 openssl ca -revoke host.pem
653
654 Next the CRL file must be updated
655
656 openssl ca -gencrl -crldays 60 -out crl.pem
657
658 The content of the CRL file can be listed with the command
659
660 openssl crl -in crl.pem -noout -text
661
662 in the case of a base64 CRL, or alternatively for a CRL in DER format
663
664 openssl crl -inform DER -in cert.crl -noout -text
665
666
667
668 4. Configuring the connections - ipsec.conf
669 ----------------------------------------
670
671 4.1 Configuring my side
672 -------------------
673
674 Usually the local side is the same for all connections. Therefore it makes
675 sense to put the definitions characterizing the strongSwan security gateway into
676 the conn %default section of the configuration file /etc/ipsec.conf. If we
677 assume throughout this document that the strongSwan security gateway is left and
678 the peer is right then we can write
679
680 conn %default
681 # my side is left - the freeswan security gateway
682 left=%defaultroute
683 leftcert=moonCert.pem
684 # load connection definitions automatically
685 auto=add
686
687 The X.509 certificate by which the strongSwan security gateway will authenticate
688 itself by sending it in binary form to its peers as part of the Internet Key
689 Exchange (IKE) is specified in the line
690
691 leftcert=moonCert.pem
692
693 The certificate can either be stored in base64 PEM-format or in the binary
694 DER-format. Irrespective of the file suffix, Pluto "automagically" determines
695 the correct format. Therefore
696
697 leftcert=moonCert.der
698
699 or
700
701 leftcert=moonCert.cer
702
703 would also be valid alternatives.
704
705 When using relative pathnames as in the examples above, the certificate files
706 must be stored in in the directory /etc/ipsec.d/certs. In order to distinguish
707 strongSwan's own certificates from locally stored trusted peer certificates
708 (see section 5.5 for details), they could also be stored in a subdirectory
709 below /etc/ipsec.d/certs as e.g. in
710
711 leftcert=mycerts/moonCert.pem
712
713 Absolute pathnames are also possible as in
714
715 leftcert=/usr/ssl/certs/moonCert.pem
716
717 As an ID for the VPN gateway we recommend the use of a Fully Qualified Domain
718 Name (FQDN) of the form
719
720 conn rw
721 right=%any
722 leftid=@moon.strongswan.org
723
724 Important: When an FQDN identifier is used it must be explicitly included as a
725 so called subjectAltName of type dnsName (DNS:) in the certificate indicated
726 by leftcert. For details on how to generate certificates with subjectAltNames,
727 please refer to section 7.2.
728
729 If you don't want to mess with subjectAltNames, you can use the certificate's
730 Distinguished Name (DN) instead, which is an identifier of type DER_ASN1_DN
731 and which can be written e.g. in the LDAP-type format
732
733 conn rw
734 right=%any
735 leftid="C=CH, O=Linux strongSwan, CN=moon.strongswan.org"
736
737 Since the subject's DN is part of the certificate, the leftid does not have to
738 be declared explicitly. Thus the entry
739
740 conn rw
741 right=%any
742
743 automatically assumes the subject DN of leftcert to be the host ID.
744
745
746 4.2 Multiple certificates
747 ---------------------
748
749 strongSwan supports multiple local host certificates and corresponding
750 RSA private keys:
751
752 conn rw1
753 right=%any
754 rightid=@peer1.domain1
755 leftcert=myCert1.pem
756 # leftid is DN of myCert1
757
758 conn rw2
759 right=%any
760 rightid=@peer2.domain2
761 leftcert=myCert2.pem
762 # leftid is DN of myCert2
763
764 When peer1 initiates a connection then strongSwan will send myCert1 and will
765 sign with myKey1 defined in /etc/ipsec.secrets (see section 6.2) whereas
766 myCert2 and myKey2 will be used in a connection setup started from peer2.
767
768
769 4.3 Configuring the peer side using CA certificates
770 -----------------------------------------------
771
772 Now we can proceed to define our connections. In many applications we might
773 have dozens of mostly Windows-based road warriors connecting to a central
774 strongSwan security gateway. The following most simple statement:
775
776 conn rw
777 right=%any
778
779 defines the general roadwarrior case. The line right=%any literally means that
780 any IPSec peer is accepted, regardless of its current IP source address and its
781 ID, as long as the peer presents a valid X.509 certificate signed by a CA the
782 strongSwan security gateway puts explicit trust in. Additionally the signature
783 during IKE main mode gives proof that the peer is in possession of the private
784 RSA key matching the public key contained in the transmitted certificate.
785
786 The ID by which a peer is identifying itself during IKE main mode can by any of
787 the ID types IPV4_ADDR, FQDN, USER_FQDN or DER_ASN1_DN. If one of the first
788 three ID types is used, then the accompanying X.509 certificate of the peer
789 must contain a matching subjectAltName field of the type ipAddress (IP:),
790 dnsName (DNS:) or rfc822Name (email:), respectively. With the fourth type
791 DER_ASN1_DN the identifier must completely match the subject field of the
792 peer's certificate. One of the two possible representations of a
793 Distinguished Name (DN) is the LDAP-type format
794
795 rightid="C=CH, O=Linux strongSwan, CN=sun.strongswan.org"
796
797 Additional whitespace can be added everywhere as desired since it will be
798 automatically eliminated by the X.509 parser. An exception is the single
799 whitespace between individual words , like e.g. in Linux strongSwan, which is
800 preserved by the parser.
801
802 The Relative Distinguished Names (RDNs) can alternatively be separated by a
803 slash '/' instead of a comma ','
804
805 rightid="/C=CH/O=Linux strongSwan/CN=sun.strongswan.org"
806
807 This is the representation extracted from the certificate by the OpenSSL
808 command line option
809
810 openssl x509 -in sunCert.pem -noout -subject
811
812 The following RDNs are supported by strongSwan
813
814 +---------------------------------------------------+
815 | DC Domain Component |
816 |---------------------------------------------------|
817 | C Country |
818 |---------------------------------------------------|
819 | ST State or province |
820 |---------------------------------------------------|
821 | L Locality or town |
822 |---------------------------------------------------|
823 | O Organisation |
824 |---------------------------------------------------|
825 | OU Organisational Unit |
826 |---------------------------------------------------|
827 | CN Common Name |
828 |---------------------------------------------------|
829 | ND NameDistinguisher, used with CN |
830 |---------------------------------------------------|
831 | N Name |
832 |---------------------------------------------------|
833 | G Given name |
834 |---------------------------------------------------|
835 | S Surname |
836 |---------------------------------------------------|
837 | I Initials |
838 |---------------------------------------------------|
839 | T Personal title |
840 |---------------------------------------------------|
841 | E E-mail |
842 |---------------------------------------------------|
843 | Email E-mail |
844 |---------------------------------------------------|
845 | emailAddress E-mail |
846 |---------------------------------------------------|
847 | SN Serial number |
848 |---------------------------------------------------|
849 | serialNumber Serial number |
850 |---------------------------------------------------|
851 | D Description |
852 |---------------------------------------------------|
853 | ID X.500 Unique Identifier |
854 |---------------------------------------------------|
855 | UID User ID |
856 |---------------------------------------------------|
857 | TCGID [Siemens] Trust Center Global ID |
858 |---------------------------------------------------|
859 | unstructuredName Unstructured Name |
860 |---------------------------------------------------|
861 | UN Unstructured Name |
862 |---------------------------------------------------|
863 | employeeNumber Employee Number |
864 |---------------------------------------------------|
865 | EN Employee Number |
866 +---------------------------------------------------+
867
868 With the roadwarrior connection definition listed above, an IPsec SA for
869 the strongSwan security gateway moon.strongswan.org itself can be established.
870 If any roadwarrior should be able to reach e.g. the two subnets 10.1.0.0/24
871 and 10.1.3.0/24 behind the security gateway then the following connection
872 definitions will make this possible
873
874 conn rw1
875 right=%any
876 leftsubnet=10.1.0.0/24
877
878 conn rw3
879 right=%any
880 leftsubnet=10.1.3.0/24
881
882 If not all peers in possession of a X.509 certificate signed by a specific
883 certificate authority shall be given access to the Linux security gateway,
884 then either a subset of them can be barred by listing the serial numbers of
885 their certificates in a certificate revocation list (CRL) as specified in
886 section 5.2 or as an alternative, access can be controlled by explicitly
887 putting a roadwarrior entry for each eligible peer into ipsec.conf:
888
889 conn sun
890 right=%any
891 rightid=@sun.strongswan.org
892
893 conn carol
894 right=%any
895 rightid=carol@strongswan.org
896
897 conn dave
898 right=%any
899 rightid="C=CH, O=Linux strongSwan, CN=dave@strongswan.org"
900
901 When the IP address of a peer is known to be stable, it can be specified as
902 well. This entry is mandatory when the strongSwan host wants to act as the
903 initiator of an IPSec connection.
904
905 conn sun
906 right=192.168.0.2
907 rightid=@sun.strongswan.org
908
909 conn carol
910 right=192.168.0.100
911 rightid=carol@strongswan.org
912
913 conn dave
914 right=192.168.0.200
915 rightid="C=CH, O=Linux strongSwan, CN=dave@strongswan.org"
916
917 conn venus
918 right=192.168.0.50
919
920 In the last example the ID types FQDN, USER_FQDN, DER_ASN1_DN and IPV4_ADDR,
921 respectively, were used. Of course all connection definitions presented so far
922 have included the lines in the conn %defaults section, comprising among other
923 a left and leftcert entry.
924
925
926 4.4 Handling Virtual IPs and wildcard subnets
927 -----------------------------------------
928
929 Often roadwarriors are behind NAT-boxes with IPsec passthrough, which causes
930 the inner IP source address of an IPsec tunnel to be different from the
931 outer IP source address usually assigned dynamically by the ISP.
932 Whereas the varying outer IP address can be handled by the right=%any
933 construct, the inner IP address or subnet must always be declared in a
934 connection definition. Therefore for the three roadwarriors rw1 to rw3
935 connecting to a strongSwan security gateway the following entries are
936 required in /etc/ipsec.conf:
937
938 conn rw1
939 right=%any
940 righsubnet=10.4.0.5/32
941
942 conn rw2
943 right=%any
944 rightsubnet=10.4.0.47/32
945
946 conn rw3
947 right=%any
948 rightsubnet=10.4.0.128/28
949
950 With the wildcard parameter rightsubnetwithin these three entries can be
951 reduced to the single connection definition
952
953 conn rw
954 right=%any
955 rightsubnetwithin=10.4.0.0/24
956
957 Any host will be accepted (of course after successful authentication based on
958 the peer's X.509 certificate only) if it declares a client subnet lying totally
959 within the brackets defined by the wildcard subnet definition (in our example
960 10.4.0.0/24). For each roadwarrior a connection instance tailored to the
961 subnet of the particular client will be created,based on the generic
962 rightsubnetwithin template.
963
964 This strongSwan feature can also be helpful with VPN clients getting a
965 dynamically assigned inner IP from a DHCP server located on the NAT router box.
966
967
968 4.5 Protocol and Port Selectors
969 ---------------------------
970
971 strongSwan offer the possibility to restrict the protocol and optionally the
972 ports in an IPsec SA using the rightprotoport and leftprotoport parameters.
973
974 Some examples:
975
976 conn icmp
977 right=%any
978 rightprotoport=icmp
979 left=%defaultroute
980 leftid=@moon.strongswan.org
981 leftprotoport=icmp
982
983 conn http
984 right=%any
985 rightprotoport=6
986 left=%defaultroute
987 leftid=@moon.strongswan.org
988 leftprotoport=6/80
989
990 conn l2tp # with port wildcard for Mac OS X Panther interoperability
991 right=%any
992 rightprotoport=17/%any
993 left=%defaultroute
994 leftid=@moon.strongswan.org
995 leftprotoport=17/1701
996
997 conn dhcp
998 right=%any
999 rightprotoport=udp/bootpc
1000 left=%defaultroute
1001 leftid=@moon.strongswan.org
1002 leftsubnet=0.0.0.0/0 #allows DHCP discovery broadcast
1003 leftprotoport=udp/bootps
1004 rekey=no
1005 keylife=20s
1006 rekeymargin=10s
1007 auto=add
1008
1009 Protocols and ports can be designated either by their numerical values
1010 or by their acronyms defined in /etc/services.
1011
1012 ipsec status
1013
1014 shows the following connection definitions:
1015
1016 "icmp": 192.168.0.1[@moon.strongswan.org]:1/0...%any:1/0
1017 "http": 192.168.0.1[@moon.strongswan.org]:6/80...%any:6/0
1018 "l2tp": 192.168.0.1[@moon.strongswan.org]:17/1701...%any:17/%any
1019 "dhcp": 0.0.0.0/0===192.168.0.1[@moon.strongswan.org]:17/67...%any:17/68
1020
1021 Based on the protocol and port selectors appropriate eroutes will be set
1022 up, so that only the specified payload types will pass through the IPsec
1023 tunnel.
1024
1025
1026 4.6 IPsec policies based on wildcards
1027 ---------------------------------
1028
1029 In large VPN-based remote access networks there is often a requirement that
1030 access to the various parts of an internal network must be granted selectively,
1031 e.g. depending on the group membership of the remote access user. strongSwan
1032 makes this possible by applying wildcard filtering on the VPN user's
1033 distinguished name (ID_DER_ASN1_DN).
1034
1035 Let's make a practical example:
1036
1037 An organization has a sales department (OU=Sales) and a research group
1038 (OU=Research). In the company intranet there are separate subnets for Sales
1039 (10.0.0.0/24) and Research (10.0.1.0/24) but both groups share a common web
1040 server (10.0.2.100). The VPN clients use Virtual IP addresses that are either
1041 assigned statically or via DHCP-over-IPsec. The sales and research departments
1042 use IP addresses from separate DHCP address pools (10.1.0.0/24) and (10.1.1.0/24),
1043 respectively. An X.509 certificate is issued to each employee, containing in its
1044 subject distinguished name the country (C=CH), the company (O=ACME),
1045 the group membership(OU=Sales or OU=Research) and the common name (e.g.
1046 CN=Bart Simpson).
1047
1048 The IPsec policy defined above can now be enforced with the following three
1049 IPsec security associations:
1050
1051 conn sales
1052 right=%any
1053 rightid="C=CH, O=ACME, OU=Sales, CN=*"
1054 rightsubnetwithin=10.1.0.0/24 # Sales DHCP range
1055 leftsubnet=10.0.0.0/24 # Sales subnet
1056
1057 conn research
1058 right=%any
1059 rightid="C=CH, O=ACME, OU=Research, CN=*"
1060 rightsubnetwithin=10.1.1.0/24 # Research DHCP range
1061 leftsubnet=10.0.1.0/24 # Research subnet
1062
1063 conn web
1064 right=%any
1065 rightid="C=CH, O=ACME, OU=*, CN=*"
1066 rightsubnetwithin=10.1.0.0/23 # Remote access DHCP range
1067 leftsubnet=10.0.2.100/32 # Web server
1068 rightprotoport=tcp # TCP protocol only
1069 leftprotoport=tcp/http # TCP port 80 only
1070
1071 Of course group specific tunneling could be implemented on the
1072 basis of the Virtual IP range specified by the rightsubnetwithin
1073 parameter alone, but the wildcard matching mechanism guarantees that
1074 only authorized user can access the corresponding subnets.
1075
1076 The '*' character is used as a wildcard in relative distinguished names (RDNs).
1077 In order to match a wildcard template, the ID_DER_ASN1_DN of a peer must contain
1078 the same number of RDNs (selected from the list in section 4.3) appearing in the
1079 exact order defined by the template.
1080
1081 "C=CH, O=ACME, OU=Research, OU=Special Effects, CN=Bart Simpson"
1082
1083 matches the templates
1084
1085 "C=CH, O=ACME, OU=Research, OU=*, CN=*"
1086
1087 "C=CH, O=ACME, OU=*, OU=Special Effects, CN=*"
1088
1089 "C=CH, O=ACME, OU=*, OU=*, CN=*"
1090
1091 but not the template
1092
1093 "C=CH, O=ACME, OU=*, CN=*"
1094
1095 which doesn't have the same number of RDNs.
1096
1097
1098 4.7 IPsec policies based on CA certificates
1099 ---------------------------------------
1100
1101 As an alternative to the wildcard based IPsec policies described in section 4.6,
1102 access to specific client host and subnets can abe controlled on the basis of
1103 the CA that issued the peer certificate
1104
1105
1106 conn sales
1107 right=%any
1108 rightca="C=CH, O=ACME, OU=Sales, CN=Sales CA"
1109 rightsubnetwithin=10.1.0.0/24 # Sales DHCP range
1110 leftsubnet=10.0.0.0/24 # Sales subnet
1111
1112 conn research
1113 right=%any
1114 rightca="C=CH, O=ACME, OU=Research, CN=Research CA"
1115 rightsubnetwithin=10.1.1.0/24 # Research DHCP range
1116 leftsubnet=10.0.1.0/24 # Research subnet
1117
1118 conn web
1119 right=%any
1120 rightca="C=CH, O=ACME, CN=ACME Root CA"
1121 rightsubnetwithin=10.1.0.0/23 # Remote access DHCP range
1122 leftsubnet=10.0.2.100/32 # Web server
1123 rightprotoport=tcp # TCP protocol only
1124 leftprotoport=tcp/http # TCP port 80 only
1125
1126 In the example above, the connection "sales" can be used by peers
1127 presenting certificates issued by the Sales CA, only. In the same way,
1128 the use of the connection "research" is restricted to owners of certificates
1129 issued by the Research CA. The connection "web" is open to both "Sales" and
1130 "Research" peers because the required "ACME Root CA" is the issuer of the
1131 Research and Sales intermediate CAs. If no rightca parameter is present
1132 then any valid certificate issued by one of the trusted CAs in
1133 /etc/ipsec.d/cacerts can be used by the peer.
1134
1135 The leftca parameter usually doesn't have to be set explicitly because
1136 by default it is set to the issuer field of the certificate loaded via
1137 leftcert. The statement
1138
1139 rightca=%same
1140
1141 sets the CA requested from the peer to the CA used by the left side itself
1142 as e.g. in
1143
1144 conn sales
1145 right=%any
1146 rightca=%same
1147 leftcert=mySalesCert.pem
1148
1149
1150 4.8 Sending certificate requests
1151 ----------------------------
1152
1153 The presence of a rightca parameter also causes the CA to be sent as
1154 part of the certificate request message when strongSwan is the initiator.
1155 A special case occurs when strongSwan responds to a roadwarrior. If several
1156 roadwarrior connections based on different CAs are defined then all eligible
1157 CAs will be listed in Pluto\92s certificate request message.
1158
1159
1160 4.9 IPsec policies based on group attributes
1161 ----------------------------------------
1162
1163 X.509 attribute certificates are the most powerful mechanism for implementing
1164 IPsec security policies. The rightgroups parameter in a connection definition
1165 restricts the access to members of the listed groups only. An IPsec peer must
1166 have a valid attribute certificate issued by a trusted Authorization Authority
1167 and listing one of the requirede group attributes in order to get admitted.
1168
1169 conn sales
1170 right=%any
1171 rightgroups="Sales"
1172 rightsubnetwithin=10.1.0.0/24 # Sales DHCP range
1173 leftsubnet=10.0.0.0/24 # Sales subnet
1174
1175 conn research
1176 right=%any
1177 rightgroups="Research"
1178 rightsubnetwithin=10.1.1.0/24 # Research DHCP range
1179 leftsubnet=10.0.1.0/24 # Research subnet
1180
1181 conn web
1182 right=%any
1183 rightgroups="Sales, Research"
1184 rightsubnetwithin=10.1.0.0/23 # Remote access DHCP range
1185 leftsubnet=10.0.2.100/32 # Web server
1186 rightprotoport=tcp # TCP protocol only
1187 leftprotoport=tcp/http # TCP port 80 only
1188
1189 In the examples above membership of the group "Sales" is required for
1190 connection sales and membership of "Research" for connection research
1191 whereas connection web is accessible for both groups.
1192
1193 Currently the attribute certificates of the peers must be loaded statically
1194 via the /etc/ipsec.d/acerts/ directory. In future releases of strongSwan it
1195 will be possible to fetch them from an LDAP directory server.
1196
1197
1198 5. Configuring certificates and CRLs
1199 ---------------------------------
1200
1201
1202 5.1 Installing the CA certificates
1203 ------------------------------
1204
1205 X.509 certificates received by strongSwan during the IKE protocol are
1206 automatically authenticated by going up the trust chain until a self-signed
1207 root CA certificate is reached. Usually host certificates are directly signed
1208 by a root CA, but strongSwan also supports multi-level hierarchies with
1209 intermediate CAs in between. All CA certificates belonging to a trust chain
1210 must be copied in either binary DER or base64 PEM format into the directory
1211
1212 /etc/ipsec.d/cacerts/
1213
1214
1215 5.2 Installing optional certificate revocation lists (CRLs)
1216 -------------------------------------------------------
1217
1218 By copying a CA certificate into /etc/ipsec.d/cacerts/, automatically all user
1219 or host certificates issued by this CA are declared valid. Unfortunately
1220 private keys might get compromised inadvertently or intentionally, personal
1221 certificates of users leaving a company have to be blocked immediately, etc.
1222 To this purpose certificate revocation lists (CRLs) have been created. CRLs
1223 contain the serial numbers of all user or host certificates that have been
1224 revoked due to various reasons.
1225
1226 After successful verification of the X.509 trust chain, Pluto searches its
1227 list of CRLs either obtained by loading them from the /etc/ipsec.d/crls/
1228 directory or fetching them dynamically from a HTTP or LDAP server for the
1229 presence of a CRL issued by the CA that has signed the certificate.
1230
1231 If the serial number of the certificate is found in the CRL then the public key
1232 contained in the certificate is declared invalid and the IPSec SA will not be
1233 established. If no CRL is found or if the deadline defined in the nextUpdate
1234 field of the CRL has been reached, a warning is issued but the public key will
1235 nevertheless be accepted. CRLs must be stored either in binary DER or base64 PEM
1236 format in the crls directory. Section 7.3 will explain in detail how CRLs can
1237 be created using OpenSSL.
1238
1239
1240 5.3 Dynamic update of certificates and CRLs
1241 ---------------------------------------
1242
1243 Pluto reads certificates and CRLs from their respective files during system
1244 startup and keeps them in memory in the form of chained lists. X.509
1245 certificates have a finite life span defined by their validity field. Therefore
1246 it must be possible to replace CA or OCSP certificates kept in system memory
1247 without disturbing established ISAKMP SAs. Certificate revocation lists should
1248 also be updated in the regular intervals indicated by the nextUpdate field in
1249 the CRL body. The following interactive commands allow the manual replacement
1250 of the various files:
1251
1252 +---------------------------------------------------------------------------+
1253 | ipsec rereadsecrets reload file /etc/ipsec.secrets |
1254 |---------------------------------------------------------------------------|
1255 | ipsec rereadcacerts reload all files in /etc/ipsec.d/cacerts/ |
1256 |---------------------------------------------------------------------------|
1257 | ipsec rereadaacerts reload all files in /etc/ipsec.d/aacerts/ |
1258 |---------------------------------------------------------------------------|
1259 | ipsec rereadocspcerts reload all files in /etc/ipsec.d/ocspcerts/ |
1260 |---------------------------------------------------------------------------|
1261 | ipsec rereadacerts reload all files in /etc/ipsec.d/acerts/ |
1262 |---------------------------------------------------------------------------|
1263 | ipsec rereadcrls reload all files in /etc/ipsec.d/crls/ |
1264 |---------------------------------------------------------------------------|
1265 | ipsec rereadall ipsec rereadsecrets |
1266 | rereadcacerts |
1267 | rereadaacerts |
1268 | rereadocspcerts |
1269 | rereadacerts |
1270 | rereadcrls |
1271 |---------------------------------------------------------------------------|
1272 | ipsec purgeocsp purge the OCSP cache and fetching requests |
1273 +---------------------------------------------------------------------------+
1274
1275 CRLs can also be automatically fetched from an HTTP or LDAP server by using
1276 the CRL distribution points contained in X.509 certificates. The command
1277
1278 ipsec listcrls
1279
1280 shows any pending fetch requests:
1281
1282 Oct 31 00:29:53 2002, trials: 2
1283 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
1284 distPts: 'http://crl.strongswan.org/strongswan.crl'
1285 'ldap://ldap.strongswan.org/o=Linux strongSwan, c=CH
1286 ?certificateRevocationList?base
1287 ?(objectClass=certificationAuthority)'
1288
1289 In the example above, an http and an ldap URL were extracted from a received
1290 end certificate. An independent thread then tries to fetch a CRL from the
1291 designated distribution points. The same thread also periodically checks
1292 if any loaded CRLs are about to expire. The check interval can be defined in
1293 the "config setup" section of the ipsec.conf file:
1294
1295 config setup
1296 crlcheckinterval=600
1297
1298 In our example the thread wakes up every 600 seconds or 10 minutes in order
1299 to check the validity of the CRLs or to retry any pending fetch requests:
1300
1301 List of X.509 CRLs:
1302
1303 Dec 19 09:35:31 2002, revoked certs: 40
1304 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
1305 distPts: 'http://crl.strongswan.org/strongswan.crl'
1306 updates: this Dec 19 09:35:00 2002
1307 next Dec 19 10:35:00 2002 warning (expires in 19 minutes)
1308
1309 List of fetch requests:
1310
1311 Dec 19 10:15:31 2002, trials: 1
1312 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
1313 distPts: 'http://crl.strongwan.org/strongswan.crl'
1314
1315 The first trial to update a CRL is started 2*crlcheckinterval before the
1316 nextUpdate time, i.e. when less than 20 minutes are left in our practical
1317 example. When crlcheckinterval is set to 0 (this is also the default value
1318 when the parameter is not set in ipsec.conf) then the CRL checking and updating
1319 thread is not started and dynamic CRL fetching is disabled.
1320
1321
1322 5.4 Local caching of CRLs
1323 ---------------------
1324
1325 The the ipsec.conf option
1326
1327 config setup
1328 cachecrls=yes
1329
1330 activates the local caching of CRLs that were dynamically fetched from an
1331 HTTP or LDAP server. Cached copies are stored in /etc/ipsec.d/crls under a
1332 unique filename formed from the issuer's SubjectKeyIdentifier and the suffix .crl.
1333
1334 With the cached copy the CRL is immediately available after pluto's startup.
1335 When the local copy is about to expire it is automatically replaced with an
1336 updated CRL fetched from one of the defined CRL distribution points.
1337
1338
1339 5.5 Online Certificate Status Protocol (OCSP)
1340 -----------------------------------------
1341
1342 The Online Certificate Status Protocol is defined by RFC 2560. It can be
1343 used to query an OCSP server about the current status of an X.509 certificate
1344 and is often used as a more dynamic alternative to a static Certificate
1345 Revocation List (CRL). Both the OCSP request sent by the client and the OCSP
1346 response messages returned by the server are transported via a standard
1347 TCP/HTTP connection. Therefore cURL support must be enabled in pluto/Makefile:
1348
1349 # Uncomment this line to enable OCSP fetching using HTTP
1350 LIBCURL=1
1351
1352 In the simplest OCSP setup, a default URI under which the OCSP server for a
1353 given CA can be accessed is defined in ipsec.conf:
1354
1355 config setup
1356 crlcheckinterval=600
1357
1358 ca strongswan
1359 cacert=strongswanCert.pem
1360 ocspuri=http://ocsp.strongswan.org:8880
1361 auto=add
1362
1363 The HTTP port can be freely chosen. In our example we have assumed TCP port 8880.
1364 The crlcheckinterval must be set to a value different from zero. Otherwise the
1365 OCSP fetching thread will not be started.
1366
1367 The well-known openssl-0.9.7 package from http://www.openssl.org implements
1368 an OCSP server that can be used in conjunction with an openssl-based Public
1369 Key Infrastructure. The OCSP client integrated into Pluto does not contain
1370 any OpenSSL code though, but is based on the existing ASN.1 functionality of
1371 strongSwan.
1372
1373 The OpenSSL-based OCSP server is started with the following command:
1374
1375 openssl ocsp -index index.txt -CA strongswanCert.pem -port 8880 \
1376 -rkey ocspKey.pem -rsigner ocspCert.pem \
1377 -resp_no_certs -nmin 60 -text
1378
1379 The command consists of the parameters
1380
1381 -index index.txt is a copy of the OpenSSL index file containing the list of
1382 all issued certificates. The certificate status in indext.txt
1383 is designated either by V for valid or R for revoked. If
1384 a new certificate is added or if a certificate is revoked
1385 using the openssl ca command, the OCSP server must be restarted
1386 in order for the changes in index.txt to take effect.
1387
1388 -CA the CA certificate
1389
1390 -port the HTTP port the OCSP server is listening on.
1391
1392 -rkey the private key used to sign the OCSP response. The use of the
1393 sensitive CA private key is not recommended since this could
1394 jeopardize the security of your production PKI if the OCSP
1395 server is hacked. It is much better to generate a special
1396 RSA private key just for OCSP signing use instead.
1397
1398 -rsigner the certificate of the OCSP server containing a public key which
1399 matches the private key defined by -rkey and which can be used by
1400 the client to check the trustworthiness of the signed OCSP response.
1401
1402 -resp_no_certs With this option the OCSP signer certificate defined by
1403 -rsigner is not included in the OCSP response.
1404
1405 -nmin the validity interval of an OCSP response given in minutes.
1406 2*crlcheckinterval before the expiration of the OCSP responses,
1407 a new query will by pro-actively started by the Pluto fetching thread.
1408
1409 If nmin is missing or set to zero then the default validity interval
1410 compiled into Pluto will be 2 minutes, leading to a quasi one-time
1411 use of the OCSP status response which will not be periodically
1412 refreshed by the fetching thread. In conjunction with the parameter
1413 setting "strictcrlpolicy=yes" a real-time certificate status query
1414 can be implemented in this way.
1415
1416 -text This option activates a verbose logging output, showing the contents
1417 of both the received OCSP request and sent OCSP response.
1418
1419 How does Pluto get hold of the OCSP signer certificate? There are two
1420 possibilities:
1421
1422 Either you put the OCSP certificate into the default directory
1423
1424 /etc/ipsec.d/ocspcerts
1425
1426 or alternatively Pluto can receive it as part of the OCSP response from the
1427 remote OCSP server. In the latter case, how can Pluto make sure that
1428 the server has indeed been authorized by the CA to deal out certificate status
1429 information? In order to ascertain the OCSP signer capability, an extended
1430 key usage attribute can be included in the OCSP server certificate. Just
1431 insert the parameter
1432
1433 extendedKeyUsage=OCSPSigner
1434
1435 in the [ usr_cert ] section of your openssl.cnf configuration file before
1436 the CA signs the OCSP server certificate.
1437
1438 For a given CA the corresponding ca section in ipsec.conf (see section 7) allows
1439 to define the URI of a single OCSP server. As an alternative an OCSP URI can be
1440 embedded into each host and user certificate by putting the line
1441
1442 authorityInfoAccess = OCSP;URI:http://ocsp.strongswan.org:8880
1443
1444 into the [ usr_cert ] section of your openssl.cnf configuration file.
1445 If an OCSP authorityInfoAccess extension is present in a certificate then this
1446 record overrides the default URI defined by the ca section.
1447
1448
1449 5.6 CRL Policy
1450 ----------
1451
1452 By default Pluto is quite tolerant concerning the handling of CRLs. It is not
1453 mandatory for a CRL to be present in /etc/ipsec.d/crls and if the expiration
1454 date defined by the nextUpdate field of a CRL has been reached just a warning
1455 is issued but a peer certificate will always be accepted if it has not been
1456 revoked.
1457
1458 If you want to enforce a stricter CRL policy then you can do this by setting
1459 the "strictcrlpolicy" option. This is done in the "config setup" section
1460 of the ipsec.conf file:
1461
1462 config setup
1463 strictcrlpolicy=yes
1464 ...
1465
1466 A certificate received from a peer will not be accepted if no corresponding
1467 CRL or OCSP response is available. And if an ISAKMP SA re-negotiation takes
1468 place after the nextUpdate deadline has been reached, the peer certificate
1469 will be declared invalid and the cached RSA public key will be deleted, causing
1470 the connection in question to fail. Therefore if you are going to use the
1471 "strictcrlpolicy=yes" option, make sure that the CRLs will always be updated
1472 in time. Otherwise a total standstill would ensue.
1473
1474 As mentioned earlier the default setting is "strictcrlpolicy=no"
1475
1476
1477 5.7 Configuring the peer side using locally stored certificates
1478 -----------------------------------------------------------
1479
1480 If you don't want to use trust chains based on CA certificates as proposed in
1481 section 4.3 you can alternatively import trusted peer certificates directly
1482 into Pluto. Thus you do not have to rely on the certificate to be transmitted
1483 by the peer as part of the IKE protocol.
1484
1485 With the conn %default section defined in section 4.1 and the use of the
1486 rightcert keyword for the peer side, the connection definitions in section 4.3
1487 can alternatively be written as
1488
1489 conn sun
1490 right=%any
1491 rightid=@sun.strongswan.org
1492 rightcert=sunCert.cer
1493
1494 conn carol
1495 right=192.168.0.100
1496 rightcert=carolCert.der
1497
1498 If the peer certificates are loaded locally then there is no sense in sending
1499 any certificates to the other end via the IKE Main Mode protocol. Especially
1500 if self-signed certificates are used which wouldn't be accepted any way by
1501 the other side. In these cases it is recommended to add
1502
1503 leftsendcert=never
1504
1505 to the connection definition[s] in order to avoid the sending of the host's
1506 own certificate. The default value is
1507
1508 leftsendcert=always.
1509
1510 If a peer certificate contains a subjectAltName extension, then an alternative
1511 rightid type can be used, as the example "conn sun" shows. If no rightid
1512 entry is present then the subject distinguished name contained in the
1513 certificate is taken as the ID.
1514
1515 Using the same rules concerning pathnames that apply to strongSwan's own
1516 certificates, the following two definitions are also valid for trusted peer
1517 certificates:
1518
1519 rightcert=peercerts/carolCert.der
1520
1521 or
1522
1523 rightcert=/usr/ssl/certs/carolCert.der
1524
1525
1526 6. Installing the private key - ipsec.secrets
1527 ------------------------------------------
1528
1529 6.1 Loading private key files in PKCS#1 format
1530 ------------------------------------------
1531
1532 Besides strongSwan's raw private key format strongSwan has been enabled to
1533 load RSA private keys in the PKCS#1 file format. The key files can be
1534 optionally secured with a passphrase.
1535
1536 RSA private key files are declared in /etc/ipsec.secrets using the syntax
1537
1538 : RSA <my keyfile> "<optional passphrase>"
1539
1540 The key file can be either in base64 PEM-format or binary DER-format. The
1541 actual coding is detected "automagically" by Pluto. The example
1542
1543 : RSA moonKey.pem
1544
1545 uses a relative pathname. In this case Pluto will look for the key file
1546 in the directory
1547
1548 /etc/ipsec.d/private
1549
1550 As an alternative an absolute pathname can be given as in
1551
1552 : RSA /usr/ssl/private/moonKey.pem
1553
1554 In both cases make sure that the key files are root readable only.
1555
1556 Often a private key must be transported from the Certification Authority
1557 where it was generated to the target security gateway where it is going
1558 to be used. In order to protect the key it can be encrypted with 3DES
1559 using a symmetric transport key derived from a cryptographically strong
1560 passphrase.
1561
1562 openssl genrsa -des3 -out moonKey.pem 1024
1563
1564 Because of the weak security, key files protected by single DES will not
1565 be accepted by Pluto!!!
1566
1567 Once on the security gateway the private key can either be permanently
1568 unlocked so that it can be used by Pluto without having to know a
1569 passphrase
1570
1571 openssl rsa -in moonKey.pem -out moonKey.pem
1572
1573 or as an option the key file can remain secured. In this case the passphrase
1574 unlocking the private key must be added after the pathname in
1575 /etc/ipsec.secrets
1576
1577 : RSA moonKey.pem "This is my passphrase"
1578
1579 Some CAs distribute private keys embedded in a PKCS#12 file. Since Pluto
1580 is not able yet to read this format directly, the private key part must
1581 first be extracted using the command
1582
1583 openssl pkcs12 -nocerts -in moonCert.p12 -out moonKey.pem
1584
1585 if the key file moonKey.pem is to be secured again by a passphrase, or
1586
1587 openssl pkcs12 -nocerts -nodes -in moonCert.p12 -out moonKey.pem
1588
1589 if the private key is to be stored unlocked.
1590
1591
1592 6.2 Entering passphrases interactively
1593 ----------------------------------
1594
1595 On a VPN gateway you would want to put the passphrase protecting the private
1596 key file right into /etc/ipsec.secrets as described in the previous paragraph,
1597 so that the gateway can be booted in unattended mode. The risk of keeping
1598 unencrypted secrets on a server can be minimized by putting the box into a
1599 locked room. As long as no one can get root access on the machine the private
1600 keys are safe.
1601
1602 On a mobile laptop computer the situation is quite different. The computer can
1603 be stolen or the user is leaving it unattended so that unauthorized persons
1604 can get access to it. In theses cases it would be preferable not to keep any
1605 passphrases openly in /etc/ipsec.secrets but to prompt for them interactively
1606 instead. This is easily done by defining
1607
1608 : RSA moonKey.pem %prompt
1609
1610 Since strongSwan is usually started during the boot process, usually no
1611 interactive console windows is available which can be used by Pluto to
1612 prompt for the passphrase. This must be initiated by the user by typing
1613
1614 ipsec secrets
1615
1616 which actually is an alias for the existing command
1617
1618 ipsec rereadsecrets
1619
1620 and which causes the prompt
1621
1622 need passphrase for '/etc/ipsec.d/private/moonKey.pem'
1623 Enter:
1624
1625 to appear. If the passphrase was correct and the private key file could be
1626 successfully decrypted then
1627
1628 valid passphrase
1629
1630 results. Otherwise the prompt
1631
1632 invalid passphrase, please try again
1633 Enter:
1634
1635 will give you another try. Entering a carriage return will abort the
1636 the passphrase prompting.
1637
1638
1639 6.3 Multiple private keys
1640 ---------------------
1641
1642 strongSwan supports multiple private keys. Since the connections defined
1643 in ipsec.conf can find the correct private key based on the public key
1644 contained in the certificate assigned by leftcert, default private key
1645 definitions without specific IDs can be used
1646
1647 : RSA myKey1.pem "<optional passphrase1>"
1648
1649 : RSA myKey2.pem "<optional passphrase2>"
1650
1651
1652 7. Configuring CA properties - ipsec.conf
1653 --------------------------------------
1654
1655 Besides the definition of IPsec connections the ipsec.conf file can also
1656 be used to configure a few properties of the certification authorities
1657 needed to establish the X.509 trust chains. The following example shows
1658 the parameters that are currently available:
1659
1660 ca strongswan
1661 cacert=strongswanCert.pem
1662 ocspuri=http://ocsp.strongswan.org:8880
1663 crluri=http://crl.strongswan.org/strongswan.crl'
1664 crluri2="ldap:///O=Linux strongSwan, C=CH?certificateRevocationList"
1665 ldaphost=ldap.strongswan.org
1666 auto=add
1667
1668 In a similar way as conn sections are used for connection definitions, an
1669 arbitrary number of optional ca sections define the basic properties of CAs.
1670
1671 Each ca section is named with a unique label
1672
1673 ca strongswan
1674
1675 The only mandatory parameter is
1676
1677 cacert=strongswanCert.pem
1678
1679 which points to the CA certificate which usually resides in the default
1680 directory /etc/ipsec.d/cacerts/ but could also be retrieved via an absolute
1681 path name. If the CA certificate is stored on a smartcard then the
1682 notation
1683
1684 cacert=%smartcard#<n>
1685
1686 or alternatively
1687
1688 cacert=%smartcard<optional slot nr>:<key id>
1689
1690 can be used. The selection of smartcard slots is described in more detail
1691 in section 8.1.
1692
1693 From the certificate the CA's distinguished name and the serial number
1694 is extracted. If an optional subjectKeyAuthentifier is present then it can
1695 be used to uniquely identify consecutive generations of CA certificates
1696 carrying the same distinguished name.
1697
1698 The OCSP URI
1699
1700 ocspuri=http://ocsp.strongswan.org:8880
1701
1702 allows to define an individual OCSP server per CA. Also up to two additional
1703 CRL distribution points (CDPs) can be defined
1704
1705 crluri=http://crl.strongswan.org/strongswan.crl'
1706 crluri2="ldap:///O=Linux strongSwan, C=CH?certificateRevocationList"
1707
1708 which are added to any CDPs already present in the received certificates
1709 themselves. The last parameter
1710
1711 ldaphost=ldap.strongswan.org
1712
1713 can be used to fill in the actual server name in LDAP CDPs where the host is missing
1714 as e.g. in the crluri2 above. In future releases this ldaphost parameter might be used
1715 to retrieve user, host and attribute certificates.
1716
1717
1718 With the auto=add statement the ca definition is automatically loaded into Pluto during
1719 system startup. Setting auto=ignore will ignore the ca section. Additional ca definitions
1720 can be loaded from ipsec.conf during runtime with the command
1721
1722 ipsec auto --type ca --add strongswan-sales
1723
1724 and
1725
1726 ipsec auto --type ca --delete strongswan-sales
1727
1728 deletes the labeled ca entry. And finally the command
1729
1730 ipsec auto --type ca --replace strongswan
1731
1732 first deletes the old definition in Pluto's memory and then loads the updated version
1733 from ipsec.conf. Any parameters which appear in several ca definitions can be put in
1734 a common ca %default section
1735
1736 ca %default
1737 ldaphost=ldap.strongswan.org
1738
1739
1740 8. Smartcard support
1741 -----------------
1742
1743 8.1 Configuring a smartcard-based connection
1744 ----------------------------------------
1745
1746 Defining a smartcard-based connection in ipsec.conf is easy:
1747
1748 conn sun
1749 right=192.168.0.2
1750 rightid=@sun.strongswan.org
1751 left=%defaultroute
1752 leftcert=%smartcard
1753 auto=add
1754
1755 In most cases there is a single smartcard reader or cryptotoken and only one
1756 RSA private key safely stored on the crypto device. Thus usually the entry
1757
1758 leftcert=%smartcard
1759
1760 which stands for the full notation
1761
1762 leftcert=%smartcard#1
1763
1764 is sufficient where the first certificate/private key object enumerated by
1765 the PKCS#11 module is used. If several certificate/private key objects are
1766 present then the nth object can be selected using
1767
1768 leftcert=%smartcard#<n>
1769
1770 The command
1771
1772 ipsec listcards
1773
1774 gives an overview over all certificate objects made available by the PKCS#11
1775 module.CA certificates are automatically available as trust anchors.
1776
1777 As an alternative the certificate ID and/or the slot number defined by
1778 the PKCS#11 standard can be specified using the notation
1779
1780 leftcert=%smartcard<optional slot nr>:<key id in hex format>
1781
1782 Thus
1783
1784 leftcert=%smartcard:50
1785
1786 will look in all available slots for ID 0x50 starting with the first slot
1787 (usually slot 0) whereas
1788
1789 leftcert=%smartcard4:50
1790
1791 will directly check slot 4 (which is usually the first slot on the second
1792 reader/token when using the OpenSC library) for a key with ID 0x50.
1793
1794
1795 8.2 Entering the PIN code
1796 ---------------------
1797
1798 Since the smartcard signing operation needed to sign the hash with the
1799 RSA private key during IKE Main Mode is protected by a PIN code,
1800 the secret PIN must be made available to Pluto.
1801
1802 For gateways that must be able to start IPsec tunnels automatically in
1803 unattended mode after a reboot, the secret PIN can be stored statically
1804 in ipsec.secrets
1805
1806 : PIN %smartcard "12345678"
1807
1808 or with the general notation
1809
1810 : PIN %smartcard#<n> "<PIN code>"
1811
1812 or alternatively
1813
1814 : PIN %smartcard<optional slot nr>:<key id> "<PIN code>"
1815
1816 On personal notebooks that could get stolen, you wouldn't want to store
1817 your PIN in ipsec.secrets. Thus the alternative form
1818
1819 : PIN %smartcard %prompt
1820
1821 will prompt you for the PIN when you start up the first IPsec connection
1822 using the command
1823
1824 ipsec up sun
1825
1826 The auto command calls the whack function which in turn communicates with
1827 Pluto over a socket. Since the whack function call is executed from a command
1828 window, Pluto can prompt you for the PIN over this socket connection.
1829 Unfortunately roadwarrior connections which just wait passively for peers
1830 cannot be initiated via the command window:
1831
1832 conn rw
1833 right=%any
1834 left=%defaultroute
1835 leftcert=%smartcard4:50
1836 auto=add
1837
1838 But if there is a corresponding entry
1839
1840 : PIN %smartcard4:50 %prompt
1841
1842 in ipsec.secrets, then the standard command
1843
1844 ipsec rereadsecrets
1845
1846 or the alias
1847
1848 ipsec secrets
1849
1850 can be used to enter the PIN code for this connection interactively.
1851
1852 The command
1853
1854 ipsec listcards
1855
1856 can be executed at any time to check the current status of the PIN code[s].
1857
1858
1859 8.3 PIN-pad equipped smartcard readers
1860 ----------------------------------
1861
1862 Smartcard readers with an integrated PIN-pad offer an increased security
1863 level because the PIN entry cannot be sniffed on the host computer e.g.
1864 by a surrepticiously installed key logger. In order to tell pluto not to
1865 prompt for the PIN on the host itself, the entry
1866
1867 : PIN %smartcard:50 %pinpad
1868
1869 can be used in ipsec.secrets. Because the key pad does not cache the PIN in
1870 the smartcard reader, it must be entered for every PKCS #11 session login.
1871 By default pluto does a session logout after every RSA signature. In order
1872 to avoid the repeated entry of the PIN code during the periodic IKE main
1873 mode rekeyings, the following parameter can be set in the config setup
1874 section of ipsec.conf:
1875
1876 config setup
1877 pkcs11keepstate=yes
1878
1879 The default setting is pkcs11keepstate=no.
1880
1881
1882 8.4 Configuring a smartcard with pkcsc15-init
1883 -----------------------------------------
1884
1885 strongSwan's smartcard solution is based on the PKCS#15 "Cryptographic Token
1886 Information Format Standard" fully supported by OpenSC library functions.
1887 Using the command
1888
1889 pkcs15-init --erase-card --create-pkcs15
1890
1891 a fresh PKCS#15 file structure is created on a smartcard or cryptotoken.
1892 With the next command
1893
1894 pkcs15-init --auth-id 1 --store-pin --pin "12345678" --puk "87654321"
1895 --label "my PIN"
1896
1897 a secret PIN code with auth-id 1 is stored in an unretrievable location on
1898 the smart card. The PIN will protect the RSA signing operation. If the PIN
1899 is entered incorrectly more than three times the smartcard will be locked
1900 and the PUK code can be used to unlock the card again.
1901
1902 Next the RSA private key is transferred to the smartcard
1903
1904 pkcs15-init --auth-id 1 --store-private-key myKey.pem [--id 45]
1905
1906 By default the PKCS#15 smartcard record will be assigned the id 45.
1907 Using the --id option multiple key records can be stored on a smartcard.
1908
1909 At last we load the matching X.509 certificate onto the smartcard
1910
1911 pkcs15-init --auth-id 1 --store-certificate myCert.pem [--id 45]
1912
1913 The pkcs15-tool can now be used to verify the contents of the smartcard.
1914
1915 pkcs15-tool --list-pins --list-keys --list-certificates
1916
1917 If everything is ok then you are ready to use the generated PKCS#15
1918 structure with strongSwan.
1919
1920 8.5 PKCS#11 proxy functions
1921 -----------------------
1922
1923 With the setting pkcs11keepstate=yes some PKCS#11 implementations
1924 (e.g. OpenSC) will lock the access to the smartcard as soon as pluto has
1925 opened a session and will thus prevent other application from sharing the
1926 smartcard resource. In order to solve this locking problem, strongSwan
1927 offers a PKCS#11 proxy service making use of the whack socket communication
1928 channel. The setting
1929
1930 config setup
1931 pkcs11proxy=yes
1932
1933 will enable the proxy mode that is disabled by default.
1934
1935 Currently two smartcard operations are supported: RSA encryption and
1936 RSA decryption. The notation is as follows:
1937
1938 ipsec scdecrypt <encrypted data>
1939 [--inbase 16|hex|64|base64|256|text|ascii]
1940 [--outbase 16|hex|64|base64|256|text|ascii]
1941 [--keyid <id>]
1942
1943 The default settings for inbase and outbase is hexadecimal.
1944 Thus the simplest call has the form
1945
1946 ipsec scdecrypt bb952b71920094ce0696ef9b8b26...12e6
1947
1948 and the returned result might be a decrypted 128 bit AES key
1949
1950 000 8836362e030e6707c32ffaa0bdad5540
1951
1952 The leading three characters represent the return code of the whack channel
1953 with 000 signifying that no error has occured. Here is another example showing
1954 the use of the inbase and outbase attributes
1955
1956 ipsec scdecrypt m/ewDnTs0k...woE= --inbase base64 --outbase text
1957
1958 where the result has the form
1959
1960 000 This is a secret
1961
1962 By default the first RSA private key found by the PKCS#11 enumeration is
1963 used. If a different key should be selected then the notation introduced
1964 in sections 8.1 and 8.2 can be used:
1965
1966 --keyid %smartcard:50
1967 --keyid %smartcard4:50
1968 --keyid %smartcard#3
1969
1970 with --keyid %smartcard#1 being the default. If supported by the smartcard
1971 and PKCS#11 library RSA encryption can be used with the notation
1972
1973 ipsec scencrypt <plaintext data>
1974 [--inbase 16|hex|64|base64|256|text|ascii]
1975 [--outbase 16|hex|64|base64|256|text|ascii]
1976 [--keyid <id>]
1977
1978 with the example
1979
1980 ipsec scencrypt "This is a secret" --inbase ascii --outbase 64
1981
1982 returning the expected output
1983
1984 000 m/ewDnTs0k...woE=
1985
1986
1987 9. Configuring the clients
1988 -----------------------
1989
1990 9.1 strongSwan
1991 ----------
1992
1993 A strongSwan to strongSwan connection is symmetrical. Any of the four defined
1994 ID types can be used, even different types on either end of the connection,
1995 although this wouldn't make much sense.
1996
1997 +--------------------------------------------------------------+
1998 | Connection Definition ID type subjectAltName |
1999 |--------------------------------------------------------------|
2000 | rightid (strongSwan) DER_ASN1_DN - |
2001 | FQDN DNS: |
2002 | USER_FQDN email: |
2003 | IPV4_ADDR IP: |
2004 |--------------------------------------------------------------|
2005 | leftid (strongSwan) DER_ASN1_DN - |
2006 | FQDN DNS: |
2007 | USER_FQDN email: |
2008 | IPV4_ADDR IP: |
2009 +--------------------------------------------------------------+
2010
2011
2012 9.2 PGPnet
2013 ------
2014
2015 Use the file peerCert.p12 to import PGPnet's X.509 certificate, the CA
2016 certificate, plus the encrypted private key in binary PKCS#12 format into the
2017 PGPkey tool. You will be prompted for the passphrase securing the private key.
2018
2019 Use the file myCert.pem to import the X.509 certificate of the strongSwan
2020 security gateway into the PGPkey tool. The PGPkeyTool does not accept X.509
2021 certificates in binary DER format, so it must be imported in base64 format:
2022
2023 -----BEGIN CERTIFICATE-----
2024 M...
2025
2026 ...
2027 -----END CERTIFICATE-----
2028
2029 Make sure that there is no human-readable listing of the X.509 certificate in
2030 front of the line
2031
2032 -----BEGIN CERTIFICATE-----
2033
2034 otherwise PGPnet will refuse to load the *.PEM file. Any surplus lines can
2035 either be deleted by loading the certificate into a text editor or you can
2036 apply the command
2037
2038 openssl x509 -in myCert.pem -out myCert.pem
2039
2040 to achieve the same effect.
2041
2042 With authentication based on X.509 certificates, PGPnet always sends the ID
2043 type DER_ASN1_DN, therefore rightid in the connection definition of the
2044 strongSwan security gateway must be an ASN.1 distinguished name.
2045
2046 In the receiving direction PGPnet accepts all four ID types from strongSwan.
2047
2048 +--------------------------------------------------------------+
2049 | Connection Definition ID type subjectAltName |
2050 |--------------------------------------------------------------|
2051 | rightid (PGPnet) DER_ASN1_DN - |
2052 |--------------------------------------------------------------|
2053 | leftid (strongSwan) DER_ASN1_DN - |
2054 | FQDN DNS: |
2055 | USER_FQDN email: |
2056 | IPV4_ADDR IP: |
2057 +--------------------------------------------------------------+
2058
2059
2060 9.3 SafeNet/Soft-PK/Soft-Remote
2061 ---------------------------
2062
2063 SafeNet/Soft-PK and SafeNet/Soft-Remote can be configured to send their
2064 identity either as DER_ASN1_DN, IPV4_ADDR, FQDN, or USER_FQDN.
2065 In the receiving direction SafeNet/Soft-PK and SafeNet/Soft-Remote
2066 accept all four ID types coming from strongSwan.
2067
2068 +--------------------------------------------------------------+
2069 | Connection Definition ID type subjectAltName |
2070 |--------------------------------------------------------------|
2071 | rightid (SafeNet/Soft-PK) DER_ASN1_DN - |
2072 | FQDN DNS: |
2073 | USER_FQDN email: |
2074 | IPV4_ADDR IP: |
2075 |--------------------------------------------------------------|
2076 | leftid (strongSwan) DER_ASN1_DN - |
2077 | FQDN DNS: |
2078 | USER_FQDN email: |
2079 | IPV4_ADDR IP: |
2080 +--------------------------------------------------------------+
2081
2082
2083 9.4 SSH Sentinel
2084 ------------
2085
2086 SSH Sentinel sends its identity as DER_ASN1_DN if the subjectAltName field of
2087 its certificate is empty. If a subjectAltName field is present, then the
2088 corresponding type IPV4_ADDR, FQDN, or USER_FQDN is automatically chosen.
2089 With several subjectAltName entries, the precedence of the different ID types
2090 is not quite clear. In the receiving direction SSH Sentinel accepts all four
2091 ID types from strongSwan.
2092
2093 +--------------------------------------------------------------+
2094 | Connection Definition ID type subjectAltName |
2095 |--------------------------------------------------------------|
2096 | rightid (SSH Sentinel) DER_ASN1_DN - |
2097 | FQDN DNS: |
2098 | USER_FQDN email: |
2099 | IPV4_ADDR IP: |
2100 |--------------------------------------------------------------|
2101 | leftid (strongSwan) DER_ASN1_DN - |
2102 | FQDN DNS: |
2103 | USER_FQDN email: |
2104 | IPV4_ADDR IP: |
2105 +--------------------------------------------------------------+
2106
2107
2108 9.5 Windows 2000/XP
2109 ---------------
2110
2111 Windows 2000 and Windows XP always send the ID type DER_ASN1_DN,
2112 therefore rightid in the connection definition of the strongSwan
2113 security gateway must be an ASN.1 distinguished name.In the
2114 receiving direction Windows 2000/XP accepts all four ID types
2115 from strongSwan.
2116
2117 +--------------------------------------------------------------+
2118 | Connection Definition ID type subjectAltName |
2119 |--------------------------------------------------------------|
2120 | rightid (Windows 2000/XP) DER_ASN1_DN - |
2121 |--------------------------------------------------------------|
2122 | leftid (strongSwan) DER_ASN1_D - |
2123 | FQDN DNS: |
2124 | USER_FQDN email: |
2125 | IPV4_ADDR IP: |
2126 +--------------------------------------------------------------+
2127
2128
2129 10. Monitoring functions
2130 --------------------
2131
2132 strongSwan offers the following monitoring functions:
2133
2134
2135 ipsec listalgs
2136
2137 lists all IKE and ESP cryptographic algorithms that are currently
2138 registered with strongSwan.
2139
2140 The a listing has the following form:
2141
2142 List of registered IKE Encryption Algorithms:
2143
2144 #3 OAKLEY_BLOWFISH_CBC, blocksize: 64, keylen: 128-128-256
2145 #5 OAKLEY_3DES_CBC, blocksize: 64, keylen: 192-192-192
2146 #7 OAKLEY_AES_CBC, blocksize: 128, keylen: 128-128-256
2147 #65004 OAKLEY_SERPENT_CBC, blocksize: 128, keylen: 128-128-256
2148 #65005 OAKLEY_TWOFISH_CBC, blocksize: 128, keylen: 128-128-256
2149 #65289 OAKLEY_TWOFISH_CBC_SSH, blocksize: 128, keylen: 128-128-256
2150
2151 List of registered IKE Hash Algorithms:
2152
2153 #1 OAKLEY_MD5, hashsize: 128
2154 #2 OAKLEY_SHA, hashsize: 160
2155 #4 OAKLEY_SHA2_256, hashsize: 256
2156 #6 OAKLEY_SHA2_512, hashsize: 512
2157
2158 List of registered IKE DH Groups:
2159
2160 #2 OAKLEY_GROUP_MODP1024, groupsize: 1024
2161 #5 OAKLEY_GROUP_MODP1536, groupsize: 1536
2162 #14 OAKLEY_GROUP_MODP2048, groupsize: 2048
2163 #15 OAKLEY_GROUP_MODP3072, groupsize: 3072
2164 #16 OAKLEY_GROUP_MODP4096, groupsize: 4096
2165 #17 OAKLEY_GROUP_MODP6144, groupsize: 6144
2166 #18 OAKLEY_GROUP_MODP8192, groupsize: 8192
2167
2168 List of registered ESP Encryption Algorithms:
2169
2170 #3 ESP_3DES, blocksize: 64, keylen: 168-168
2171 #7 ESP_BLOWFISH, blocksize: 64, keylen: 96-128
2172 #12 ESP_AES, blocksize: 128, keylen: 128-256
2173 #252 ESP_SERPENT, blocksize: 128, keylen: 128-256
2174 #253 ESP_TWOFISH, blocksize: 128, keylen: 128-256
2175
2176 List of registered ESP Authentication Algorithms:
2177
2178 #1 AUTH_ALGORITHM_HMAC_MD5, keylen: 128-128
2179 #2 AUTH_ALGORITHM_HMAC_SHA1, keylen: 160-160
2180 #5 AUTH_ALGORITHM_HMAC_SHA2_256, keylen: 256-256
2181 #7 AUTH_ALGORITHM_HMAC_SHA2_512, keylen: 512-512
2182
2183
2184 The command
2185
2186 ipsec listpubkeys [--utc]
2187
2188 lists all public keys currently installed in the chained list of public
2189 keys. These keys were statically loaded from ipsec.conf or aquired either
2190 from received certificates or retrieved from secure DNS servers using
2191 opportunistic mode.
2192
2193 The public key listing has the following form:
2194
2195 Feb 11 14:40:18 2005, 2048 RSA Key AwEAAa+uL,
2196 until Sep 09 13:17:25 2009 ok
2197 ID_FQDN '@moon.strongswan.org'
2198 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2199 serial: '03'
2200 Feb 11 14:40:18 2005, 2048 RSA Key AwEAAa+uL,
2201 until Sep 09 13:17:25 2009 ok
2202 ID_DER_ASN1_DN 'C=CH, O=Linux strongSwan, CN=moon.strongswan.org'
2203 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2204 serial: '03'
2205 Feb 11 13:36:53 2005, 2048 RSA Key AwEAAbgbh,
2206 until Dec 31 22:43:18 2009 ok
2207 ID_USER_FQDN 'carol@strongswan.org'
2208 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2209 serial: '0a'
2210
2211 It consists of
2212
2213 - the date the public key was installed either in local time or UTC (--utc)
2214 - the modulus size of the RSA key in bits
2215 - a keyID consisting of 9 base64 symbols representing the public exponent
2216 and the most significant bits of the modulus
2217 - the expiration date of the public key (extracted from the certificate)
2218 - the type and value of the ID associated with the public key.
2219 - the issuer of the certificate the public key was extracted from.
2220 - the serial number of the certificate the public key was extracted from.
2221
2222 A public key can be associated with several IDs, e.g. using subjectAltNames
2223 in certificates and an ID can possess several public keys, e.g. retrieved
2224 from a secure DNS server.
2225
2226
2227 The command
2228
2229 ipsec listcerts [--utc]
2230
2231 lists all local certificates, both strongSwan's own and those of
2232 trusted peer loaded via leftcert and rightcert, respectively.
2233
2234 The output has the form
2235
2236 Feb 11 13:36:47 2005, count: 4
2237 subject: 'C=CH, O=Linux strongSwan, CN=moon.strongswan.org'
2238 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2239 serial: 03
2240 pubkey: 2048 RSA Key AwEAAa+uL, has private key
2241 validity: not before Sep 10 13:17:25 2004 ok
2242 not after Sep 09 13:17:25 2009 ok
2243 subjkey: e5:e4:10:87:6c:2a:c4:be:ad:85:49:42:a6:de:76:58:30:3a:9f:c1
2244 authkey: 5d:a7:dd:70:06:51:32:7e:e7:b6:6d:b3:b5:e5:e0:60:ea:2e:4d:ef
2245 aserial: 00
2246
2247 and shows
2248
2249 - the date the certificate was installed either in local time or UTC (--utc)
2250 - the count shows how many connections refer to this certificate
2251 - the subject of the certificate
2252 - the issuer of the certificate
2253 - the serial number of the certificate
2254 - the size and keyid of the RSA public key contained in the certificate.
2255 the label "has private key" indicates that a matching RSA private key
2256 has been found, defined or loaded in ipsec.secrets.
2257 - the label "on smartcard" indicates that the certificate was loaded from
2258 a smartcard or cryptotoken and that most probably a matching RSA private
2259 key also resides on-card.
2260 - the validity of the CA certificate expressed either in local time or
2261 UTC (--utc). The validity is checked automatically resulting either
2262 in an "ok" message or a "fatal" error message.
2263 - the optional subjectKeyIdentifier extension which is a 20 byte SHA-1 hash
2264 over the certificate's public key.
2265 - the optional authorityKeyIdentifier extension which is a 20 byte SHA-1 hash
2266 over the public key of the issuer who signed the certificate.
2267 - the serial number of the issuer's certificate.
2268
2269
2270 The command
2271
2272 ipsec listcacerts [--utc]
2273
2274 lists all CA certificates that have been either been loaded from the directory
2275 /etc/ipsec.d/cacerts/ or received via the IKE protocol. The output has the form
2276
2277 Feb 11 13:36:52 2005, count: 1
2278 subject: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2279 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2280 serial: 00
2281 pubkey: 2048 RSA Key AwEAAb/yX
2282 validity: not before Sep 10 13:01:45 2004 ok
2283 not after Sep 08 13:01:45 2014 ok
2284 subjkey: 5d:a7:dd:70:06:51:32:7e:e7:b6:6d:b3:b5:e5:e0:60:ea:2e:4d:ef
2285 authkey: 5d:a7:dd:70:06:51:32:7e:e7:b6:6d:b3:b5:e5:e0:60:ea:2e:4d:ef
2286 aserial: 00
2287
2288 and shows
2289
2290 - the date the CA certificate was installed either in local time or UTC (--utc)
2291 - the count is always set to 1
2292 - the subject of the CA certificate
2293 - the issuer of the CA certificate
2294 - the serial number of the CA certificate
2295 - the size and keyid of the RSA public key contained in the certificate.
2296 - the validity of the CA certificate expressed either in local time or
2297 UTC (--utc). The validity is checked automatically resulting either
2298 in an "ok" message or a "fatal" error message.
2299 - the optional subjectKeyIdentifier extension which is a 20 byte SHA-1 hash
2300 over the CA certificate's public key.
2301 - the optional authorityKeyIdentifier extension which is a 20 byte SHA-1 hash
2302 over the public key of the issuer who signed the CA certificate.
2303 For Root CA certificates the authorityKeyIdentifier and subjectKeyIdentifier
2304 fields must be equal.
2305 - the serial number of the issuer's certificate.
2306
2307
2308 The command
2309
2310 ipsec listaacerts [--utc]
2311
2312 lists all Authorization Authority certificates that have been loaded from
2313 the directory /etc/ipsec.d/aacerts/.
2314 The output has the form
2315
2316 Dec 20 13:29:55 2004, count: 1
2317 subject: 'C=CH, O=strongSec GmbH, CN=strongSec Authorization Authority'
2318 issuer: 'C=CH, O=strongSec GmbH, CN=strongSec Root CA'
2319 serial: 0f
2320 pubkey: 2048 RSA Key AwEAAfazH
2321 validity: not before Aug 24 13:41:56 2003 ok
2322 not after Aug 23 13:41:56 2005 ok
2323 subjkey: 56:89:b9:28:c9:1b:a0:00:7f:50:9d:ec:28:75:23:c1:1e:d1:dd:90
2324 authkey: af:80:d5:c6:02:1c:96:78:b3:85:a5:65:a2:23:fd:ad:cf:e2:55:b2
2325 aserial: 00
2326
2327 and shows
2328
2329 - the date the AA certificate was installed either in local time or UTC (--utc)
2330 - the count is always set to 1
2331 - the subject of the AA certificate
2332 - the issuer of the AA certificate
2333 - the serial number of the AA certificate
2334 - the size and keyid of the RSA public key contained in the certificate.
2335 - the validity of the AA certificate expressed either in local time or
2336 UTC (--utc). The validity is checked automatically resulting either
2337 in an "ok" message or a "fatal" error message.
2338 - the optional subjectKeyIdentifier extension which is a 20 byte SHA-1 hash
2339 over the AA certificate's public key.
2340 - the optional authorityKeyIdentifier extension which is a 20 byte SHA-1 hash
2341 over the public key of the issuer who signed the AA certificate.
2342 - the serial number of the issuer's certificate.
2343
2344
2345 The command
2346
2347 ipsec listocspcerts [--utc]
2348
2349 lists all OCSO signer certificates that have been either loaded from
2350 /etc/ipsec.d/ocspcerts/ or have been received included in the OCSP server
2351 response. The output has the form
2352
2353 Feb 09 22:56:17 2005, count: 1
2354 subject: 'C=CH, O=Linux strongSwan, OU=OCSP, CN=ocsp.strongswan.org'
2355 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2356 serial: 09
2357 pubkey: 2048 RSA Key AwEAAaonT
2358 validity: not before Nov 19 17:29:28 2004 ok
2359 not after Nov 18 17:29:28 2009 ok
2360 subjkey: 88:07:0a:b8:ae:c7:c1:07:5c:be:68:6a:c4:a5:7f:81:1f:37:b5:56
2361 authkey: 5d:a7:dd:70:06:51:32:7e:e7:b6:6d:b3:b5:e5:e0:60:ea:2e:4d:ef
2362 aserial: 00
2363
2364 and shows
2365
2366 - the date the OCSP signer certificate was installed either in local time
2367 or UTC (--utc)
2368 - the count is always set to 1
2369 - the subject of the OCSP signer certificate
2370 - the issuer of the OCSP signer certificate
2371 - the serial number of the OCSP signer certificate
2372 - the size and keyid of the RSA public key contained in the certificate.
2373 - the validity of the OCSP signer certificate expressed either in local time
2374 or UTC (--utc). The validity is checked automatically resulting either
2375 in an "ok" message or a "fatal" error message.
2376 - the optional subjectKeyIdentifier extension which is a 20 byte SHA-1 hash
2377 over the OCSP signer certificate's public key.
2378 - the optional authorityKeyIdentifier extension which is a 20 byte SHA-1 hash
2379 over the public key of the issuer who signed the OCSP certificate.
2380 - the serial number of the issuer's certificate.
2381
2382
2383 The command
2384
2385 ipsec listacerts [--utc]
2386
2387 lists all X.509 attribute certificates that have been loaded from the directory
2388 /etc/ipsec.d/acerts/.
2389 The output has the form
2390
2391 Dec 20 13:29:56 2004
2392 holder: 'C=CH, O=strongSec GmbH, CN=Andreas Steffen'
2393 hissuer: 'C=CH, O=strongSec GmbH, CN=strongSec Root CA'
2394 hserial: 1e
2395 groups: Research, Sales
2396 issuer: 'C=CH, O=strongSec GmbH, CN=strongSec Authorization Authority'
2397 serial: 2c
2398 validity: not before Dec 19 14:51:38 2004 ok
2399 not after Dec 20 14:51:38 2004 fatal (expired)
2400 authkey: 56:89:b9:28:c9:1b:a0:00:7f:50:9d:ec:28:75:23:c1:1e:d1:dd:90
2401 aserial: 0f
2402
2403 and shows
2404
2405 - the date the attribute certificate was installed either in local time
2406 or UTC (--utc)
2407 - the holder of the attribute certificate
2408 - the issuer of holder's certificate
2409 - the serial number of the holder's certificate
2410 - the group attributes
2411 - the issuing Authorization Authority of the attribute certificate
2412 - the serial number of the attribute certificate
2413 - the validity of the attribute certificate expressed either in local time or
2414 UTC (--utc). The validity is checked automatically resulting either
2415 in an "ok" message or a "fatal" error message.
2416 - an authorityKeyIdentifier extension which is a 20 byte SHA-1 hash
2417 over the public key of the issuing Authorization Authority
2418 - the serial number of the AA certificate.
2419
2420
2421 The command
2422
2423 ipsec listgroups [--utc]
2424
2425 lists all group attributes either defined in right|leftgroups statements
2426 in ipsec.conf or contained in loaded X.509 attribute certificates.
2427 The output has the form
2428
2429 Dec 20 13:29:55 2004, count: 4
2430 Research
2431 Dec 20 13:30:04 2004, count: 1
2432 Research New York
2433 Dec 20 13:29:55 2004, count: 3
2434 Sales
2435
2436 and shows
2437
2438 - the date the group attribute was first installed either in local time
2439 or UTC (--utc)
2440 - the count shows how many times the attribute is used
2441 - the group name
2442
2443
2444 The command
2445
2446 ipsec listcainfos [--utc]
2447
2448 lists the properties defined by the ca definition sections in ipsec.conf.
2449 The output has the form
2450
2451 Jun 08 22:31:37 2004, "strongswan"
2452 authname: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2453 ldaphost: 'ldap.strongswan.org'
2454 ocspuri: 'http://ocsp.strongswan.org:8880'
2455 distPts: 'http://crl.strongswan.org/strongswan.crl'
2456 'ldap:///O=Linux strongSwan, C=CH?certificateRevocationList'
2457 authkey: 5d:a7:dd:70:06:51:32:7e:e7:b6:6d:b3:b5:e5:e0:60:ea:2e:4d:ef
2458 aserial: 00
2459
2460 and shows
2461
2462 - the date the CA definition was loaded either in local time or UTC (--utc)
2463 - the name of the ca section
2464 - the distinguished name of the CA
2465 - an optional default ldap host for the CA
2466 - an optional OCSP URI
2467 - a maximum of two optional CRL distribution points
2468 - the optional authorityKeyIdentifier extension which is a 20 byte SHA-1 hash
2469 over the public key of the CA.
2470 - the serial number of the CA.
2471
2472
2473 The command
2474
2475 ipsec listcrls [--utc]
2476
2477 lists all CRLs that have been loaded from /etc/ipsec.d/crls/.
2478 The output has the form
2479
2480 Feb 11 13:37:00 2005, revoked certs: 1
2481 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2482 distPts: 'http://crl.strongswan.org/strongswan.crl'
2483 updates: this Feb 08 07:46:29 2005
2484 next Mar 10 07:46:29 2005 ok
2485 authkey: 5d:a7:dd:70:06:51:32:7e:e7:b6:6d:b3:b5:e5:e0:60:ea:2e:4d:ef
2486 aserial: 00
2487
2488 and shows
2489
2490 - the date the CRL was installed either in local time or UTC (--utc)
2491 - the number revoked certificates
2492 - the issuer of the CRL
2493 - the URLs of the distribution points where the CRL can be fetched from.
2494 - the dates when the CRL was issued and when the next update
2495 is expected, respectively, expressed either in local time or
2496 UTC (--utc). It is automatically checked if the next update
2497 deadline has passed, resulting either in an "ok" message, a
2498 a "warning" message when strictcrlpolicy=no or a "fatal" message when
2499 strictcrlpolicy=yes.
2500 - the optional authorityKeyIdentifier extension which is a 20 byte SHA-1 hash
2501 over the public key of the issuer who signed the CRL. This extension is
2502 present in version 2 CRLs, only.
2503 - the serial number of the issuer's certificate.
2504
2505
2506 The command
2507
2508
2509 ipsec listocsp [--utc]
2510
2511 lists the contents of the OCSP response cache. The output has the form
2512
2513 issuer: 'C=CH, O=Linux strongSwan, CN=strongSwan Root CA'
2514 uri: 'http://ocsp.strongswan.org:8880'
2515 authname: 13:9d:a0:9e:f4:32:ab:8f:e2:89:56:67:fa:d0:d4:e3:35:86:71:b9
2516 authkey: 5d:a7:dd:70:06:51:32:7e:e7:b6:6d:b3:b5:e5:e0:60:ea:2e:4d:ef
2517 aserial: 00
2518 Feb 09 22:56:17 2005, until Feb 09 23:01:17 2005 warning (expires in 4 minutes)
2519 serial: 0a, good
2520
2521 and shows
2522
2523 - the distinguished name of the CA handled by the OCSP server
2524 - the http URI of the OCSP server.
2525 - the 20 byte SHA-1 hash of the CA's distinguished name
2526 - the 20 byte SHA-1 hash of the CA's public key
2527 - the serial number of the CA's certificate
2528 - a certificate status list showing
2529 - the time the OCSP status was received
2530 - an optional nextUpdate deadline (if missing the OCSP status will be
2531 onetime with a lifetime of 2 minutes only).
2532 - the serial number of the certificate
2533 - the status of the certificate (good, revoked, unknown)
2534
2535
2536 The command
2537
2538 ipsec listcards [--utc]
2539
2540 lists all smartcard records that are currently in use by Pluto.
2541 The output has the form
2542
2543 Aug 17 16:47:59 2005, #1, count: 6
2544 slot: 0, session closed, logged out, has valid pin
2545 id: 45
2546 label: 'strongSwan'
2547 subject: 'C=CH, O=Linux strongSwan, CN=carol@strongswan.org'
2548
2549 with pkcs11keepstate=no and
2550
2551 Aug 17 16:47:59 2005, #1, count: 6
2552 slot: 0, session opened, logged in, has pin pad
2553 id: 45
2554 label: 'strongSwan'
2555 subject: 'C=CH, O=Linux strongSwan, CN=carol@strongswan.org'
2556
2557 with pkcs11keepstate=yes and shows
2558
2559 - the date the certificate was read from the smartcard record
2560 - the certificate objects are numbered starting from #1
2561 - the count shows how many connections and secret pin entries point
2562 to the smartcard record
2563 - the PKCS #11 slot number
2564 - the PKCS #11 session state: closed | opened
2565 - the PKCS #11 session login state: logged out | logged in
2566 - the status of the PIN: no pin | valid pin | invalid pin | pin pad
2567 - the ID of the certificate object
2568 - the label of the certificate object
2569 - the subject distinguished name of the certificate
2570
2571
2572 The command
2573
2574 ipsec auto --listall [--utc]
2575
2576 is equivalent to
2577
2578 ipsec listalgs
2579 ipsec listpubkeys [--utc]
2580 ipsec listcerts [--utc]
2581 ipsec listcacerts [--utc]
2582 ipsec listaacerts [--utc]
2583 ipsec listocspcerts [--utc]
2584 ipsec listacerts [--utc]
2585 ipsec listgroups [--utc]
2586 ipsec listcainfos [--utc]
2587 ipsec listcrls [--utc]
2588 ipsec listocsp [--utc]
2589 ipsec listcards [--utc]
2590
2591
2592 11. Firewall support functions
2593 --------------------------
2594
2595
2596 11.1 Environment variables in the updown script
2597 ------------------------------------------
2598
2599 strongSwan makes the following environment variables available
2600 in the updown script indicated by the leftupdown option:
2601
2602 +------------------------------------------------------------------+
2603 | Variable Example Comment |
2604 |------------------------------------------------------------------|
2605 | $PLUTO_PEER_ID carol@strongswan.org USER_FQDN (1) |
2606 |------------------------------------------------------------------|
2607 | $PLUTO_PEER_PROTOCOL 17 udp (2) |
2608 |------------------------------------------------------------------|
2609 | $PLUTO_PEER_PORT 68 bootpc (3) |
2610 |------------------------------------------------------------------|
2611 | $PLUTO_PEER_CA C=CH, O=ACME, CN=Sales CA (4) |
2612 |------------------------------------------------------------------|
2613 | $PLUTO_MY_ID @moon.strongswan.org FQDN (1) |
2614 |------------------------------------------------------------------|
2615 | $PLUTO_MY_PROTOCOL 17 udp (2) |
2616 |------------------------------------------------------------------|
2617 | $PLUTO_MY_PORT 67 bootps (3) |
2618 +------------------------------------------------------------------+
2619
2620 (1) $PLUTO_PEER_ID/$PLUTO_MY_ID contain the IDs of the two ends
2621 of an established connection. In our examples these
2622 correspond to the strings defined by rightid and leftid,
2623 respectively.
2624
2625 (2) $PLUTO_PEER_PROTOCOL/$PLUTO_MY_PROTOCOL contain the protocol
2626 defined by the rightprotoport and leftprotoport options,
2627 respectively. Both variables contain the same protocol value.
2628 The variables take on the value '0' if no protocol has been defined.
2629
2630 (3) $PLUTO_PEER_PORT/$PLUTO_MY_PORT contain the ports defined by
2631 the rightprotoport and leftprotoport options, respectively.
2632 The variables take on the value '0' if no port has been defined.
2633
2634 (4) $PLUTO_PEER_CA contains the distinguished name of the CA that
2635 issued the peer's certificate.
2636
2637
2638 11.2 Automatic insertion and deletion of iptables firewall rules
2639 -----------------------------------------------------------
2640
2641 Starting with strongswan-2.7.0, the default _updown script automatically inserts
2642 and deletes dynamic iptables firewall rules upon the establishment or teardown,
2643 respectively, of an IPsec security association. This new feature is activated
2644 with the line
2645
2646 leftfirewall=yes
2647
2648 and can be used when the following prerequisites are fulfilled:
2649
2650 - Linux 2.4.x kernel, KLIPS IPsec stack, and arbitrary iptables version.
2651 Filtering of tunneled traffic is based on ipsecN interfaces.
2652
2653 - Linux 2.4.16 kernel or newer, native NETKEY IPsec stack, and
2654 iptables-1.3.5 or newer. Filtering of tunneled traffic is based on
2655 IPsec policy matching rules.
2656
2657 If you define a local client subnet with a netmask larger than /32 behind
2658 the gateway then the automatically inserted FORWARD iptables rules will
2659 not allow to access the internal IP address of the host although it is
2660 part of the client subnet definition. If you want additional INPUT and
2661 OUTPUT iptables rules to be inserted, so that the host itself can be accessed
2662 then add the following line:
2663
2664 lefthostaccess=yes
2665
2666 The _updown script also features a logging facility which will register the
2667 creation (+) and the expiration (-) of each successfully established VPN
2668 connection in a special syslog file in the following concise and easily
2669 readable format:
2670
2671 Jul 19 18:58:38 moon vpn:
2672 + @carol.strongswan.org 192.168.0.100 -- 192.168.0.1 == 10.1.0.0/16
2673 Jul 19 22:15:17 moon vpn:
2674 - @carol.strongswan.org 192.168.0.100 -- 192.168.0.1 == 10.1.0.0/16
2675
2676
2677 11.3 Sample Linux 2.6 updown script for iptables < 1.3.5
2678 ---------------------------------------------------
2679
2680 If you are using a Linux 2.6 kernel older than 2.6.16 or an iptables version
2681 older than 1.3.5 then the IPsec policy matching rules will not be available.
2682 In order to make sure that only tunneled packets are accepted, a mark can be
2683 set on incoming ESP packets. This "ESP" mark will be retained on the
2684 decapsulated packet so that iptables rules inserted by the updown script can
2685 check on the presence of this mark. For this purpose the template located in
2686
2687 programs/_updown_espmark
2688
2689 can be used. Store a copy of _updown_espmark e.g. in /etc/ipsec.updown and load
2690 the script with the line
2691
2692 leftupdown=/etc/updown.ipsec.
2693
2694 In addition for the dynamic updown script to work the following static iptables rules
2695 must be applied:
2696
2697 iptables -t mangle -A INPUT -p 50 -j MARK --set-mark 50
2698
2699
2700 12. Authentication with raw RSA public keys
2701 ---------------------------------------
2702
2703 FreeS/WAN, as it is available from www.freeswan.org does public key
2704 authentication with raw RSA public keys that are directly defined in
2705 /etc/ipsec.conf
2706
2707 rightrsasigkey=0sAq4c....
2708
2709 When version 1.x of standard FreeS/WAN receives a certificate request (CR),
2710 it immediately drops the negotiation because it does not know how to answer
2711 the request. As a workaround strongSwan does not send a CR if the RSA
2712 key has been statically loaded using [right/left]rsasigkey. A problem
2713 remains with roadwarriors initiating a connection. Since strongSwan
2714 does not know the identity of the initiating peer in advance, it will always
2715 send a CR, causing the rupture of the IKE negotiation if the peer is a
2716 version 1.x FreeS/WAN host. To circumvent this problem the configuration
2717 parameter 'nocrsend' can be set in the config setup section of /etc/ipsec.conf:
2718
2719 config setup:
2720 nocrsend=yes
2721
2722 With this entry no certificate request is sent in any connection.
2723 The default setting is nocrsend=no.
2724
2725
2726 13. Authentication with OpenPGP certificates
2727 ----------------------------------------
2728
2729 strongSwan also supports RSA based authentication using OpenPGP
2730 certificates and OpenPGP V3 fingerprints used as an KEY_ID identifier.
2731
2732
2733 13.1 OpenPGP certificates
2734 --------------------
2735
2736 OpenPGP certificates containing RSA public keys can now directly be loaded
2737 in ASCII armored PGP format using the leftcert and rightcert parameters
2738 in /etc/ipsec.conf:
2739
2740 conn pgp
2741 right=%any
2742 righcert=peerCert.asc
2743 left=%defaultroute
2744 leftcert=gatewayCert.asc
2745
2746 The peer certificate must be stored locally (the default directory is
2747 /etc/ipsec.d/certs) since currently no trust can be established for
2748 PGP certificates received from a peer via the IKE protocol.
2749
2750
2751 13.2 OpenPGP private keys
2752 --------------------
2753
2754 PGP private keys in unencrypted form can now directly be loaded in ASCII
2755 armored PGP format via an entry in /etc/ipsec.secrets:
2756
2757 : RSA gatewayKey.asc
2758
2759 Existing IDEA-encrypted RSA private keys can be unlocked with GnuPG and
2760 the IDEA extension (see http://www.gnupg.org/gph/en/pgp2x.html) using
2761 the commands
2762
2763 gpg --import gatewayCert.asc
2764
2765 gpg --allow-secret-key-import --import gatewayKey.asc
2766
2767 gpg --edit-key <gateway ID>
2768 > passwd #change to empty password
2769 > save
2770
2771 gpg -a --export-secret-key <gateway ID> gatewayKey.asc
2772
2773
2774 13.3 Monitoring functions
2775 --------------------
2776
2777 The command ipsec listcerts shows all loaded PGP certificates
2778 in the following format:
2779
2780 Aug 28 09:51:55 2002, count: 1
2781 fingerprint: 0x1ccfca12d93467ffa9d5093d87a465dc
2782 pubkey: 1024 RSA Key ARHso6uKQ
2783 created: Aug 27 08:51:39 2002
2784 until: --- -- --:--:-- ---- ok (expires never)
2785
2786 The entries are
2787
2788 - the date the certificate was loaded either in local time or UTC (--utc)
2789 - the V3 fingerprint consisting of the 16 byte MD5 hash of the public key
2790 which is used as an ID of type KEY_ID
2791 - the modulus size of the RSA key in bits
2792 - a keyID consisting of 9 base64 symbols representing the public exponent
2793 and the most significant bits of the modulus
2794 - the creation date of the public key (extracted from the certificate)
2795 - the optional expiration date of the public key (extracted from the
2796 certificate)
2797
2798
2799 13.4 Suppression of certificate request messages
2800 -------------------------------------------
2801
2802 PGPnet configured to work with OpenPGP certificates aborts the IKE
2803 negotiation when it receives a X.509 certificate. Therefore it is recommended
2804 (mandatory for roadwarrior connections) to set
2805
2806 config setup:
2807 nocrsend=yes
2808
2809 in /etc/ipsec.conf.
2810
2811
2812 14. Additional Features
2813 -------------------
2814
2815
2816 14.1 Authentication and encryption algorithms
2817 ----------------------------------------
2818
2819 strongSwan supports the following suite of encryption and authentication
2820 algorithms for both IKE and ESP payloads.
2821
2822 +------------------------------------------------------------------+
2823 | IKE algorithms (negotiated in Phase 1 Main Mode) |
2824 +------------------------------------------------------------------+
2825 | Encryption algorithms: 3des, aes, serpent, twofish, blowfish |
2826 |------------------------------------------------------------------|
2827 | Hash algorithms: md5, sha, sha2 |
2828 |------------------------------------------------------------------|
2829 | DH groups: 1024, 1536, 2048, 3072, 4096, 6144, 8192 |
2830 +------------------------------------------------------------------+
2831
2832 NOTE: For IKE the SHA-1 algorithm is denoted by "sha"
2833
2834 The cryptographic IKE algorithms listed above are a fixed part of the
2835 strongSwan distribution. Particular algorithms can be added or removed
2836 in the "programs/pluto/alg" directory.
2837
2838 +------------------------------------------------------------------+
2839 | ESP algorithms (negotiated in Phase 2 Quick Mode) |
2840 +------------------------------------------------------------------+
2841 | Encryption algorithms: 3des, aes, serpent, twofish, blowfish |
2842 |------------------------------------------------------------------|
2843 | Hash algorithms: md5, sha1, sha2 |
2844 |------------------------------------------------------------------|
2845 | PFS groups: 1024, 1536, 2048, 3072, 4096, 6144, 8192 |
2846 +------------------------------------------------------------------+
2847
2848 The cryptographic ESP algorithms listed above are a fixed part of the
2849 strongSwan distribution. If your Linux 2.4 or 2.6 kernel includes the
2850 CryptoAPI then additional ESP algorithms can be added or deleted as
2851 kernel modules.
2852
2853 The IKE and ESP cryptographic algorithms to be proposed to the peer
2854 as an initiator can be specified on a per connection basis in the form
2855
2856 conn normal
2857 ...
2858 ike=aes128-sha-modp1536,3des-sha-modp1536
2859 esp=aes128-sha1,3des-sha1
2860 ...
2861
2862 or if you are more paranoid
2863
2864 conn paranoid
2865 ...
2866 ike=aes256-sha2_512-modp2048
2867 esp=aes256-sha2_512
2868 ...
2869
2870 If the the "ike" and "esp" configuration parameters are missing in
2871 ipsec.conf, then the default settings
2872
2873 ike=3des-md5-modp1536,3des-sha-modp1536,\
2874 3des-md5-modp1024,3des-sha-modp1024
2875 esp=3des-md5,3des-sha1
2876
2877 arre implicitly assumed. The 3DES encryption algorithm and the MD5 and
2878 SHA-1 hash algorithms are hardcoded into strongSwan and cannot be removed.
2879
2880 If Perfect Forward Secrecy (PFS is desired), then a PFS group can be
2881 optionally specified:
2882
2883 conn make_sure
2884 ...
2885 pfs=yes
2886 pfsgroup=modp2048,modp1536
2887 ...
2888
2889 If the "pfs" parameter is missing then "pfs=yes" is assumed by default.
2890 This means that PFS must be disabled explicitly by setting "pfs=no".
2891
2892 If the "pfsgroup" parameter is missing then the default is
2893
2894 pfsgroup=<Phase1 DH group>
2895
2896 The "ike" and "esp" parameters are used to formulate one or several
2897 transform proposals to the peer if the strongSwan VPN host is the initiator.
2898 Attention! As a responder the first proposal from the peer is accepted that
2899 is supported the by one of the registered algorithms listed by the command
2900
2901 ipsec listalgs
2902
2903 If the responder wants to restrict the allowed cipher suites the '!' flag
2904 can be used to do so. The configuration
2905
2906 conn normal_but_strict
2907 ...
2908 ike=aes128-sha-modp1536,3des-sha-modp1536!
2909 esp=aes128-sha1,3des-sha1!
2910 ...
2911
2912 will only permit the listed algorithms defined above but no other methods
2913 even if they might be supported by the responder.
2914
2915
2916 14.2 NAT traversal
2917 -------------
2918
2919 Currently please refer to README.NAT-Traversal document in the strongSwan
2920 distribution.
2921
2922
2923 14.3 Dead peer detection
2924 --------------------
2925
2926 strongSwan implements the RFC 3706 Dead Peer Detection (DPD) keep-alive
2927 scheme. If an established IPsec SA has been idle (i.e. without any traffic)
2928 for N seconds (dpddelay=N) then strongSwan side sends a "hello" message
2929 (R_U_THERE) and the peer replies with an acknowledge message (R_U_THERE_ACK).
2930 If no response is received, the R_U_THERE messages are repeated until a DPD
2931 timeout of M seconds (dpdtimeout=M) has elapsed. If still no traffic or
2932 R_U_THERE_ACK packets were received, the peer is declared to be dead and all
2933 SAs belonging to a common Phase 1 SA are deleted.
2934
2935 DPD support is tuneable on a per connection basis by using the dpdaction,
2936 dpddelay and dpdtimeout directives:
2937
2938 conn roadwarrior
2939 right=%any
2940 left=%defaultroute
2941 leftsubnet=10.1.0.0/16
2942 dpdaction=clear
2943
2944 conn net-to-net
2945 right=192.168.0.2
2946 rightsubnet=10.2.0.0/16
2947 left=%defaultroute
2948 leftsubnet=10.1.0.0/16
2949 dpdaction=hold
2950 dpddelay=60
2951 dpdtimeout=500
2952
2953 In the first example dpdaction=clear activates the DPD mechanism under the
2954 condition that the peer supports RFC 3706. The values dpddelay=30s and
2955 dpdtimeout=120s are assumed by default in the absence of these parameters, so
2956 that during idle periods an R_U_THERE packet is sent every 30 seconds. If no
2957 traffic or a no R_U_THERE_ACK packet is received from the peer within a
2958 120 second time span, the peer will be declared dead and all SAs and associated
2959 eroutes will be cleared.
2960
2961 In the second example R_U_THERE packets are sent every 60 seconds and the
2962 parameter setting dpdaction=hold will put the eroute of the ruptured connection
2963 into a %trap state, so that when new outgoing traffic will occur, the
2964 correspondig connection will be automatically renegotiated as soon as the
2965 peer is up again.
2966
2967 It is recommended to use dpdaction=hold for statically defined connections and
2968 dpdaction=clear for dynamic roadwarrior connections. The default value is
2969 dpdaction=none, which disables DPD.
2970
2971
2972 14.4 IKE Mode Config
2973 ---------------
2974
2975 The IKE Mode Config protocol <draft-ietf-ipsec-isakmp-mode-cfg-04.txt> allows
2976 the dynamic assignment of virtual IP addresses and optional DNS and WINS server
2977 information to IPsec clients. Currently only "Mode Config Pull Mode" is
2978 implemented where the client actively sends a Mode Config request to the server
2979 in order to obtain a virtual IP.
2980
2981 Client side configuration (carol):
2982
2983 conn home
2984 right=192.168.0.1
2985 rightsubnet=10.1.0.0/16
2986 rightid=@moon.strongswan.org
2987 left=%defaultroute
2988 leftsourceip=%modeconfig
2989 leftcert=carolCert.pem
2990 leftid=carol@strongswan.org
2991 auto=start
2992
2993 Server side configuration (moon):
2994
2995 conn roadwarrior
2996 right=%any
2997 rightid=carol@strongswan.org
2998 rightsourceip=10.3.0.1
2999 left=%defaultroute
3000 leftsubnet=10.1.0.0/16
3001 leftcert=moonCert.pem
3002 leftid=@moon.strongswan.org
3003 auto=add
3004
3005 The wildcard %modeconfig or %modecfg used in the leftsourceip parameter of the
3006 client will trigger a Mode Config request. Currently the server will return
3007 the virtual IP address defined by the rightsourceip parameter. In the future
3008 an LDAP-based lookup mechanism will be supported.
3009
3010
3011 15. Copyright statement and acknowledgements
3012 ----------------------------------------
3013
3014
3015 FreeS/WAN version base system:
3016
3017 Copyright (c) 1999-2004
3018 Henry Spencer, Richard Guy Briggs,
3019 D. Hugh Redelmeier, Sandy Harris, Claudia Schmeing,
3020 Michael Richardson, Angelos D. Keromytis, John Ioannidis,
3021
3022 NAT-Traversal, ipsec starter, Delete SA and Notification messages:
3023
3024 Copyright (c) 2002-2003, Mathieu Lafon
3025
3026 Additional cryptoalgorithms (AES, etc):
3027
3028 Copyright (c) 2002-2003, JuanJo Ciarlante
3029
3030 Dead Peer Detection:
3031
3032 Copyright (c) 2002-2004
3033 Ken Bantoft, JuanJo Ciarlante, Philip Craig,
3034 Pawel Krawczyk, Srinvasan Venkataraman
3035
3036 Porting to Linux 2.6 kernel:
3037
3038 Copyright (c) 2003, Herbert Xu
3039
3040 Dynamic CRL fetching:
3041
3042 Copyright (c) 2002, Stephane Laroche
3043
3044 IKE Mode Config protocol:
3045
3046 Copyright (c) 2001-2002, Colubris Networks
3047
3048 Virtual IP and source routing:
3049
3050 Copyright (c) 2003, Tuomo Soini
3051
3052 Port and protocol selectors for outbound traffic:
3053
3054 Copyright (c) 2002, Stephen J. Bevan
3055
3056 PGPnet-RSA parts of patch:
3057
3058 Copyright (c) 2000, Kai Martius
3059
3060 X.509, OCSP and smartcard functionality:
3061
3062 Copyright (c) 2000, Andreas Hess, Patric Lichtsteiner, Roger Wegmann
3063 Copyright (c) 2001, Marco Bertossa, Andreas Schleiss
3064 Copyright (c) 2002, Uli Galizzi, Ariane Seiler, Mario Strasser
3065 Copyright (c) 2002, Martin Berner, Lukas Suter
3066 Copyright (c) 2003, Christoph Gysin, Simon Zwahlen
3067 Copyright (c) 2004, David Buechi, Michael Meier
3068 Copyright (c) 2000-2005, Andreas Steffen
3069
3070 Zurich University of Applied Sciences in Winterthur, Switzerland
3071
3072 scepclient:
3073
3074 Copyright (c) 2005, Jan Hutter, Martin Willi
3075 Copyright (c) 2005-2006, Andreas Steffen
3076
3077 University of Applied Sciences in Rapperswil, Switzerland
3078
3079 This program is free software; you can redistribute it and/or modify
3080 it under the terms of the GNU General Public License as published by
3081 the Free Software Foundation; either version 2 of the License, or
3082 (at your option) any later version. See http://www.fsf.org/copyleft/gpl.txt.
3083
3084 This program is distributed in the hope that it will be useful, but
3085 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
3086 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3087 for more details.
3088 -----------------------------------------------------------------------------
3089
3090 This file is RCSID $Id: README,v 1.33 2006/04/24 21:27:49 as Exp $
3091