使用活动目录证书存储的Openvpn多重身份validation

集成的企业OpenVPNconfiguration

我试图find一个如何以安全的方式configurationopenvpn的最终来源,最重要的是100%与Active Directory集成在一起。 我懒得有多个系统照顾。 我想要:

  • OpenVPN客户端没有定制(当然除了configuration文件)
  • 与Active Directory紧密集成
  • authentication的多重因素(MS证书商店+密码)
  • 超级简单的pipe理

这是我想出来的。 这个解决scheme是否安全,是否满足上述需求?

在这一点上,我假定有一个活动的目录服务器在openvpn服务器可以连接到的地方,并且客户机连接到域。

我也将假设你有一个AD CA部署。

自动注册

这一切都始于一个古老的自动注册过程之旅。 我不打算在这里详细说明,因为本说明很好地描述了这个过程。 唯一需要注意的是我自动注册的机器证书,而不是用户证书。

一旦GPO推出,所有最终用户都将拥有由域CA签署的不可移植的私人机器证书。

现在,我们可以用OpenVPN结婚AD自动注册证书吗? 我是的。

证书颁发机构

在AD CA上,导出CA公用证书。 在我的情况下,我把它命名为最后一个.crt的机器名称。

PKIconfiguration

这些例子假设一个基于ubuntu的操作系统。 调整您的发行包和电子证书步骤。

# install our requisite packages apt-get -y install openvpn openvpn-auth-ldap # install our ca key as root ca mkdir /usr/share/ca-certificates/extra/ cat > /usr/share/ca-certificates/extra/contoso-CONAWSDC01-CA.crt << EOM -----BEGIN CERTIFICATE----- MIIDBjCCAe6gAwIBAgIQf0VK+i3wuppE8eWGBn525TANBgkqhkiG9w0BAQsFADAc ... KYTE7h9qTnJ4EQ== -----END CERTIFICATE----- EOM # enable this root ca dpkg-reconfigure ca-certificates # go to /etc/openvpn for the remainder of this exercise cd /etc/openvpn # create our private key openssl genrsa -des3 -out server.key 2048 # create a csr for the domain controller to sign. you *should* have the correct CN, but it's not required openssl req -key server.key -out server.csr # then, over on the CA, we need to sign this key (note the webserver cheat) # certreq.exe -submit -attrib "CertificateTemplate:WebServer" .\bopawsvpn02.txt # create ta.key, which is used by the tls-auth pragma to prevent DOS attacks openvpn --genkey --secret /etc/openvpn/ta.key # symlink to our ca key ln -s /usr/share/ca-certificates/extra/bop-BOPAWSDC01-CA.crt ca.crt # enable ip forwarding sysctl -w net.ipv4.ip_forward=1 # ( update /etc/sysctl.conf ) # If you are hosting the OpenVPN server on an Amazon Web Services (AWS) EC2 instance make sure "Source/Destination Checking" is disabled on the instance's Elastic Network Interface (enabled by default) 

OpenVPNconfiguration

我从基本的道路战士configuration开始,并根据我的需要调整它。 大多数情况下,我添加了DNS设置和路由。

由于依赖于LDAPvalidation的其他模块,我无法使chroot正常工作。

为server.conf

 port 1194 proto udp dev tun sndbuf 0 rcvbuf 0 ca ca.crt cert server.crt key server.key dh dh.pem tls-auth ta.key 0 topology subnet server 10.22.0.0 255.255.0.0 ifconfig-pool-persist ipp.txt push "dhcp-option DNS 10.20.1.4" push "dhcp-option DOMAIN contoso.com" push "route 10.0.0.0 255.255.0.0" push "route 192.168.1.0 255.255.255.0" keepalive 10 120 cipher AES-128-CBC comp-lzo user nobody group nogroup persist-key persist-tun status openvpn-status.log verb 3 plugin /usr/lib/openvpn/openvpn-auth-ldap.so /etc/openvpn/ldap.conf 

LDAPconfiguration

为了configurationLDAP,您需要先使用服务帐户进行绑定,然后才能请求进行身份validation。 我用很小的权限创build了一个长密码帐户。

的ldap.conf

 <LDAP> # LDAP server URL URL "ldap://10.20.1.4" # Bind DN (If your LDAP server doesn't support anonymous binds) # BindDN uid=Manager,ou=People,dc=example,dc=com BindDN "CN=auth,OU=Service Accounts,DC=contoso,DC=com" # Bind Password Password areallyreallyreallylongpassword # Network timeout (in seconds) Timeout 15 # Enable Start TLS TLSEnable no # Follow LDAP Referrals (anonymously) FollowReferrals yes # TLS CA Certificate File TLSCACertFile /usr/local/etc/ssl/ca.pem # TLS CA Certificate Directory TLSCACertDir /etc/ssl/certs # Client Certificate and key # If TLS client authentication is required #TLSCertFile /usr/local/etc/ssl/client-cert.pem #TLSKeyFile /usr/local/etc/ssl/client-key.pem # Cipher Suite # The defaults are usually fine here # TLSCipherSuite ALL:!ADH:@STRENGTH </LDAP> <Authorization> # Base DN BaseDN "OU=local,DC=contoso,DC=com" # User Search Filter #SearchFilter "(&(uid=%u)(accountStatus=active))" SearchFilter "(sAMAccountName=%u)" # Require Group Membership RequireGroup false # Add non-group members to a PF table (disabled) #PFTable ips_vpn_users </Authorization> 

客户端configuration

我想要一个单一的configuration,我会发送给所有我的用户,没有在.ovpn文件中embedded标识符或证书。 经过一些实验和cryptoapi的logging不足,我发现这个作弊。 通过在SUBJ调用cryptoapi中指定我的域,OpenVPN将find具有该名称的第一个证书,这是我的机器证书。

我不得不embeddedCA证书,因为我无法弄清楚如何从证书存储中获取证书。 但这是公开的信息,所以我并不担心。

client.ovpn

 client dev tun proto udp sndbuf 0 rcvbuf 0 remote vpn.contoso.com 1194 resolv-retry infinite nobind persist-key persist-tun remote-cert-tls server cipher AES-128-CBC comp-lzo key-direction 1 verb 3 auth-user-pass setenv opt block-outside-dns # block all non-vpn dns queries # redirect-gateway def1 # route *all* traffic through vpn # this is my domain fqdn. allows one config for multiple connections cryptoapicert "SUBJ:.contoso.com" <ca> -----BEGIN CERTIFICATE----- MIIDBjCCAe6gAwIBAgIQf0VK+i3wuppE8eWGBn525TANBgkqhkiG9w0BAQsFADAc ... KYTE7h9qTnJ4EQ== -----END CERTIFICATE----- </ca> 

我是否缺less任何明显的安全漏洞?