Answers:
这有帮助吗?
问候,威廉·M·普特
install strongswan + openssl
apt-get install strongswan openssl
创建您的CA文件:
cd /etc/ipsec.d
openssl req -x509 -days 3650 -newkey rsa:2048 -keyout \
private/strongswanKey.pem -out cacerts/strongswanCert.pem
cp cacerts/strongswanCert.pem certs/
如果您希望CA证书采用二进制DER格式,则以下命令可实现此转换:
openssl x509 -in cacerts/strongswanCert.pem -outform DER -out \
cacerts/strongswanCert.der
编辑/etc/ssl/openssl.conf
(/usr/lib/ssl/openssl.cnf
是一个符号链接):
nano -w /usr/lib/ssl/openssl.cnf
更改参数以适合您的Strongswan环境。
[ CA_default ]
dir = /etc/ipsec.d # Where everything is kept
certificate = $dir/cacerts/strongswanCert.pem # The CA certificate
private_key = $dir/private/strongswanKey.pem # The private key
创建丢失的DIR和文件:
mkdir newcerts
touch index.txt
echo “00” > serial
生成用户证书:
openssl req -newkey rsa:1024 -keyout private/hostKey.pem \
-out reqs/hostReq.pem
签约两年:
openssl ca -in reqs/hostReq.pem -days 730 -out \
certs/hostCert.pem -notext
通常,基于Windows的VPN客户端需要其私钥,其主机或用户证书以及CA证书。加载此信息最方便的方法是将所有内容放入PKCS#12文件中:
openssl pkcs12 -export -inkey private/hostKey.pem \
-in certs/hostCert.pem \
-name "host" \
-certfile cacerts/strongswanCert.pem \
-caname "strongSwan Root CA" \
-out host.p12
编辑/etc/ipsec.secrets
:
:RSA strongswanKey.pem “pempassword”
:XAUTH user "secret"
编辑/etc/ipsec.conf
:
config setup
plutodebug=none
uniqueids=yes
nat_traversal=yes
interfaces="%defaultroute"
conn %default
authby=rsasig
leftrsasigkey=%cert
rightrsasigkey=%cert
keyingtries=1
keylife=20m
ikelifetime=240m
conn iphone
auto=add
dpdaction=clear
authby=xauthrsasig
xauth=server
pfs=no
leftcert=strongswanCert.pem
left=<serverip>
leftsubnet=0.0.0.0/0
right=%any
rightsourceip=<virtual client ip> #local VPN virtual subnet
rightcert=hostCert.pem
要在iPhone上导入证书,只需将其通过电子邮件发送给您自己!在iPhone上创建ipsec vpn时,可以选择证书。
请注意,如果要进行NAT,则需要设置iptables。(查看fwbuilder)