Ipsec

使用 strongswan 的公鑰認證

  • September 1, 2015

我有兩個系統 r1 和 r2,我想在它們之間建立一個 ESP 隧道,使用公鑰身份驗證與 Strongswan。我在使用 openssl 的兩個系統中生成了公鑰,分別儲存在 r1-pub.pem 和 r2-pub.pem 中。

現在我的 ipsec.conf 文件在系統 r1 中看起來像這樣

conn host-host-rsa

left=1.1.1.1
leftsubnet=192.168.10.0/24
leftid=@moon.strongswan.org
leftauth=pubkey
leftrsasigkey=/root/r1-pub.pem
right=2.2.2.2
rightsubnet=192.168.20.0/24
rightid=@sun.strongswan.org
rightauth=pubkey
rightrsasigkey=/root/r2-pub.pem
type=tunnel
auto=add

在系統 r2 中,配置為

conn host-host-rsa
left=2.2.2.2
leftsubnet=192.168.20.0/24
leftid=@sun.strongswan.org
leftauth=pubkey
leftrsasigkey=/root/r2-pub.pem
right=1.1.1.1
rightsubnet=192.168.10.0/24
rightid=@moon.strongswan.org
rightauth=pubkey
rightrsasigkey=/root/r1-pub.pem
type=tunnel
auto=add

現在在 r1 上啟動 ipsec 時,出現此錯誤

Starting strongSwan 5.1.2 IPsec [starter]...
00[DMN] Starting IKE charon daemon (strongSwan 5.1.2, Linux 3.13.0-32-generic, x86_64)
00[CFG] loading ca certificates from '/etc/ipsec.d/cacerts'
00[CFG] loading aa certificates from '/etc/ipsec.d/aacerts'
00[CFG] loading ocsp signer certificates from '/etc/ipsec.d/ocspcerts'
00[CFG] loading attribute certificates from '/etc/ipsec.d/acerts'
00[CFG] loading crls from '/etc/ipsec.d/crls'
00[CFG] loading secrets from '/etc/ipsec.secrets'
00[LIB] loaded plugins: charon test-vectors aes rc2 sha1 sha2 md4 md5 random nonce x509 revocation constraints pkcs1 pkcs7 pkcs8 pkcs12 pem openssl xcbc cmac hmac ctr ccm gcm attr kernel-netlink resolve socket-default stroke updown eap-identity addrblock
00[LIB] unable to load 5 plugin features (5 due to unmet dependencies)
00[LIB] dropped capabilities, running as uid 0, gid 0
00[JOB] spawning 16 worker threads
charon (607) started after 300 ms
04[CFG] received stroke: add connection 'host-host-rsa'
04[LIB] building CRED_CERTIFICATE - TRUSTED_PUBKEY failed, tried 0 builders
04[CFG]   loading public key for "moon.strongswan.org" from '/root/r1-pub.pem' failed
04[LIB] building CRED_CERTIFICATE - TRUSTED_PUBKEY failed, tried 0 builders
04[CFG]   loading public key for "sun.strongswan.org" from '/root/r2-pub.pem' failed
04[CFG] added configuration 'host-host-rsa'

我不知道為什麼會發生這種載入公鑰錯誤。任何幫助將不勝感激。

您需要pubkey外掛才能使用原始公鑰。如果您指定了 charon.load,請strongswan.conf確保在列表中包含該外掛。如果你還沒有,那麼你要麼沒有建構外掛,要麼你的發行版沒有發布它。在這兩種情況下,您都必須使用適當的選項從源重建 strongSwan 。./configure

引用自:https://serverfault.com/questions/718181