Get-ChildItem -Path Cert:\LocalMachine\My
certlm.msc > Autorités de certification racines de confiance > Certificats).
certlm.msc (Certificats - Ordinateur local)..cer)
gpmc.msc (Gestion des stratégies de groupe) depuis PowerShell
*.cer)
gpupdate /force
certmgr.msc et vérifier la présence du certificat
certlm.msc
Ouverture de la console des modèles via un cmd : certlm.msc
certutil -CATemplates
PS C:\Users\Administrateur> certutil -CATemplates
OpenVPN_Server: OpenVPN_Server_Certificate -- Inscription automatique
OpenVPN_Client: OpenVPN_Client_Certificate -- Inscription automatique
IPSECIntermediateOffline: IPSec (demande hors connexion) -- Inscription automatique: Accès refusé.
CEPEncryption: Chiffrement CEP -- Inscription automatique: Accès refusé.
EnrollmentAgentOffline: Agent d’inscription Exchange (demande hors connexion) -- Inscription automatique: Accès refusé.
DirectoryEmailReplication: Réplication de la messagerie de l’annuaire -- Inscription automatique: Accès refusé.
DomainControllerAuthentication: Authentification du contrôleur de domaine -- Inscription automatique: Accès refusé.
KerberosAuthentication: Authentification Kerberos -- Inscription automatique: Accès refusé.
EFSRecovery: Agent de récupération EFS -- Inscription automatique: Accès refusé.
EFS: EFS basique -- Inscription automatique: Accès refusé.
DomainController: Contrôleur de domaine -- Inscription automatique: Accès refusé.
WebServer: Serveur Web -- Inscription automatique: Accès refusé.
Machine: Ordinateur -- Inscription automatique: Accès refusé.
User: Utilisateur -- Inscription automatique: Accès refusé.
SubCA: Autorité de certification secondaire -- Inscription automatique: Accès refusé.
Administrator: Administrateur -- Inscription automatique: Accès refusé.
CertUtil: -CATemplates La commande s’est terminée correctement.
PS C:\Users\Administrateur>
Sur le serveur VPN (172.30.0.2), Debian 13 :
ssh [email protected]
[email protected]'s password:
Linux VPN 6.12.43+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.43-1 (2025-08-27) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
cedric@VPN:~$
cedric@VPN:~$ su
Mot de passe :
root@VPN:/home/cedric#
apt update
apt upgrade -y
apt install openvpn openssl -y
/usr/sbin/ à la liste des endroits où chercher les commandes) :
export PATH=$PATH:/usr/sbin
mkdir -p /etc/openvpn/server
mkdir -p /var/log/openvpn
mkdir -p /root/cert-requests
mkdir -p /root/client-configs
chmod 700 /etc/openvpn/server
chmod 755 /var/log/openvpn
$RequestFile = @"
[Version]
Signature="`$Windows NT`$"
[NewRequest]
Subject = "CN=vpn-server-openvpn"
KeySpec = 1
KeyLength = 2048
Exportable = TRUE
MachineKeySet = TRUE
RequestType = PKCS10
KeyUsage = 0xa0
[EnhancedKeyUsageExtension]
OID=1.3.6.1.5.5.7.3.1 ; Server Authentication
OID=1.3.6.1.5.5.7.3.2 ; Client Authentication
[Extensions]
2.5.29.17 = "{text}"
_continue_ = "dns=vpn.mysoccbt.fr&"
_continue_ = "dns=vpn-server-openvpn&"
_continue_ = "ipaddress=172.30.0.2&"
"@
$RequestFile | Out-File -FilePath C:\openvpn-server.inf -Encoding ASCII -NoNewline
Write-Host "Fichier de demande créé : C:\openvpn-server.inf" -ForegroundColor Green
certreq -new C:\openvpn-server.inf C:\openvpn-server.req
Write-Host "Demande générée : C:\openvpn-server.req" -ForegroundColor Green
Write-Host "Soumission à la CA..." -ForegroundColor Yellow
certreq -submit -attrib "CertificateTemplate:OpenVPN_Server" C:\openvpn-server.req C:\openvpn-server.cer
certreq -accept C:\openvpn-server.cer
Write-Host "Certificat installé dans le magasin de l'ordinateur" -ForegroundColor Green
$cert = Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Subject -like "*vpn-server-openvpn*"}
if ($cert) {
Write-Host "" -ForegroundColor Green
Write-Host "=====================================" -ForegroundColor Green
Write-Host "CERTIFICAT SERVEUR CRÉÉ" -ForegroundColor Green
Write-Host "=====================================" -ForegroundColor Green
Write-Host "Subject : $($cert.Subject)" -ForegroundColor Yellow
Write-Host "Thumbprint : $($cert.Thumbprint)" -ForegroundColor Cyan
Write-Host "Expire le : $($cert.NotAfter)" -ForegroundColor Cyan
$pwd = ConvertTo-SecureString -String "squall969*" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath C:\openvpn-server.pfx -Password $pwd | Out-Null
Write-Host "" -ForegroundColor Green
Write-Host "Certificat exporté : C:\openvpn-server.pfx" -ForegroundColor Green
Write-Host "Mot de passe du PFX : squall969*" -ForegroundColor Yellow
Write-Host "" -ForegroundColor Green
} else {
Write-Host "ERREUR : Le certificat n'a pas été trouvé" -ForegroundColor Red
}
=====================================
CERTIFICAT SERVEUR CRÉÉ
=====================================
Subject : CN=vpn-server-openvpn
Thumbprint : DBA6C47E2DF16EDD9BFE277066046A1EAB4FBAEA
Expire le : 02/24/2028 16:12:01
Certificat exporté : C:\openvpn-server.pfx
Mot de passe du PFX : squall969*!
PS C:\Users\Administrateur>
$rootCert = Get-ChildItem -Path Cert:\LocalMachine\Root | Where-Object {$_.Subject -like "*MySocCBt-CA*"}
if ($rootCert) {
$certBytes = $rootCert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert)
$certBase64 = [System.Convert]::ToBase64String($certBytes)
$certPem = "-----BEGIN CERTIFICATE-----`n"
$certPem += ($certBase64 -replace "(.{64})", "`$1`n")
$certPem += "`n-----END CERTIFICATE-----"
$certPem | Out-File -FilePath "C:\ca-root.crt" -Encoding ASCII
Write-Host "Certificat racine exporté : C:\ca-root.crt" -ForegroundColor Green
} else {
Write-Host "Certificat racine non trouvé" -ForegroundColor Red
}
C:\\openvpn-server.pfx (certificat serveur + clé privée)C:\\ca-root.crt (certificat racine)
/root :
mv /home/cedric/ca-root.crt /root
mv /home/cedric/openvpn-server.pfx /root
Sur le serveur VPN, dans le dossier /root :
root@VPN:~# ls -l
total 20
-rw-rw-r-- 1 cedric cedric 2481 24 févr. 16:49 ca-root.crt
drwxr-xr-x 2 root root 4096 24 févr. 16:01 cert-requests
drwxr-xr-x 2 root root 4096 24 févr. 16:01 client-configs
-rw-rw-r-- 1 cedric cedric 4301 24 févr. 16:49 openvpn-server.pfx
root@VPN:~#
openssl pkcs12 -in openvpn-server.pfx -clcerts -nokeys -out server.crt
openssl pkcs12 -in openvpn-server.pfx -nocerts -nodes -out server.key
openssl pkcs12 -in openvpn-server.pfx -cacerts -nokeys -out ca-from-pfx.crt
openssl x509 -in server.crt -noout -subject
subject=CN = vpn-server-openvpncp server.crt /etc/openvpn/server/
cp server.key /etc/openvpn/server/
cp ca-root.crt /etc/openvpn/server/ca.crt
chmod 600 /etc/openvpn/server/server.key
chmod 644 /etc/openvpn/server/server.crt
chmod 644 /etc/openvpn/server/ca.crt
root@VPN:~# ls -la /etc/openvpn/server/
total 20
drwx------ 2 root root 4096 24 févr. 17:11 .
drwxr-xr-x 4 root root 4096 24 févr. 15:54 ..
-rw-r--r-- 1 root root 2481 24 févr. 17:11 ca.crt
-rw------- 1 root root 2360 24 févr. 17:11 server.crt
-rw------- 1 root root 1952 24 févr. 17:11 server.key
root@VPN:~#
Ces paramètres sont nécessaires pour l'établissement de la connexion sécurisée entre le client et le serveur. Ils permettent de négocier une clé de session partagée de manière sécurisée.
openssl dhparam -out /etc/openvpn/server/dh2048.pem 2048
root@VPN:~# ls -l /etc/openvpn/server
total 16
-rw-r--r-- 1 root root 2481 24 févr. 17:11 ca.crt
-rw-r--r-- 1 root root 428 24 févr. 17:14 dh2048.pem
-rw------- 1 root root 2360 24 févr. 17:11 server.crt
-rw------- 1 root root 1952 24 févr. 17:11 server.key
root@VPN:~#
nano /etc/openvpn/server/server.conf
# ============================================
# Configuration OpenVPN Server avec AD CS PKI
# ============================================
# Port et protocole
port 1194
proto udp
dev tun
# Certificats PKI depuis Active Directory
ca /etc/openvpn/server/ca.crt
cert /etc/openvpn/server/server.crt
key /etc/openvpn/server/server.key
dh /etc/openvpn/server/dh2048.pem
# Mode serveur TLS
tls-server
tls-version-min 1.2
# Vérification du certificat client
remote-cert-tls client
# Pool d'adresses IP pour les clients VPN
server 10.8.0.0 255.255.255.0
# Routes à pousser aux clients
push "route 172.30.0.0 255.255.255.0"
# Configuration DNS pour Active Directory
push "dhcp-option DNS 172.30.0.1"
push "dhcp-option DOMAIN MySocCBt.fr"
# Paramètres de sécurité
cipher AES-256-GCM
auth SHA256
dh none
# Paramètres de connexion
keepalive 10 120
persist-key
persist-tun
# Isolation (sécurité)
user nobody
group nogroup
# Logs
status /var/log/openvpn/openvpn-status.log
log-append /var/log/openvpn/openvpn.log
verb 3
dh none utilise le DH éphémère (ECDH) au lieu du fichier dh2048.pem#user nobody et #group nogroup si vous rencontrez des problèmes de permissionsopenvpn --config /etc/openvpn/server/server.conf --test-crypto
openvpn --config /etc/openvpn/server/server.conf
tail -f /var/log/openvpn/openvpn.log. Vous devriez voir en réponse :
root@VPN:~# tail -f /var/log/openvpn/openvpn.log
2026-02-24 21:15:01 GID set to nogroup
2026-02-24 21:15:01 Capabilities retained: CAP_NET_ADMIN
2026-02-24 21:15:01 MULTI: multi_init called, r=256 v=256
2026-02-24 21:15:01 IFCONFIG POOL IPv4: base=10.8.0.4 size=62
2026-02-24 21:15:01 Initialization Sequence Completed
2026-02-24 21:16:41 event_wait : Interrupted system call (fd=-1,code=4)
2026-02-24 21:16:41 net_route_v4_del: 10.8.0.0/24 via 10.8.0.2 dev [NULL] table 0 metric -1
2026-02-24 21:16:41 Closing TUN/TAP interface
2026-02-24 21:16:41 net_addr_ptp_v4_del: 10.8.0.1 dev tun0
2026-02-24 21:16:41 SIGINT[hard,] received, process exiting
sysctl net.ipv4.ip_forward
nano /usr/lib/sysctl.d/50-default.conf
# Rajouter la ligne à la fin du fichier
net.ipv4.ip_forward=1
sysctl -p /usr/lib/sysctl.d/50-default.conf
root@VPN:~# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
root@VPN:~#
apt install iptables -y
iptables -F
iptables -t nat -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o ens33 -j MASQUERADE
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -A FORWARD -d 10.8.0.0/24 -m state --state RELATED,ESTABLISHED -j ACCEPT
netfilter-persistent save
systemctl enable openvpn-server@server
systemctl start openvpn-server@server
systemctl status openvpn-server@server
https://ip_LAN
$ClientRequestFile = @"
[Version]
Signature="`$Windows NT`$"
[NewRequest]
Subject = "CN=client1-vpn"
KeySpec = 1
KeyLength = 2048
Exportable = TRUE
MachineKeySet = TRUE
RequestType = PKCS10
KeyUsage = 0xa0
[EnhancedKeyUsageExtension]
OID=1.3.6.1.5.5.7.3.2 ; Client Authentication
[Extensions]
2.5.29.17 = "{text}"
_continue_ = "dns=client1-vpn&"
"@
$ClientRequestFile | Out-File -FilePath C:\openvpn-client1.inf -Encoding ASCII -NoNewline
certreq -new C:\openvpn-client1.inf C:\openvpn-client1.req
certreq -submit -attrib "CertificateTemplate:OpenVPN_Client" C:\openvpn-client1.req C:\openvpn-client1.cer
certreq -accept C:\openvpn-client1.cer
$clientCert = Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Subject -like "*client1-vpn*"}
if ($clientCert) {
Write-Host "Certificat client créé : $($clientCert.Subject)" -ForegroundColor Green
$pwd = ConvertTo-SecureString -String "squall969*" -Force -AsPlainText
Export-PfxCertificate -Cert $clientCert -FilePath C:\openvpn-client1.pfx -Password $pwd | Out-Null
Write-Host "Certificat client exporté : C:\openvpn-client1.pfx" -ForegroundColor Green
Write-Host "Mot de passe : squall969*" -ForegroundColor Yellow
}
openvpn-client1.pfx vers le serveur VPN Linux.
/root/client-configs :
mv /home/cedric/openvpn-client1.pfx /root/client-configs
cd /root/client-configs
openssl pkcs12 -in openvpn-client1.pfx -clcerts -nokeys -out client1.crt
openssl pkcs12 -in openvpn-client1.pfx -nocerts -nodes -out client1.key
cp /etc/openvpn/server/ca.crt .
root@VPN:~/client-configs# ls -l
total 20
-rw-r--r-- 1 root root 2481 24 févr. 23:00 ca.crt
-rw------- 1 root root 2275 24 févr. 22:58 client1.crt
-rw------- 1 root root 1956 24 févr. 22:58 client1.key
-rw-rw-r-- 1 cedric cedric 4245 24 févr. 22:53 openvpn-client1.pfx
root@VPN:~/client-configs#
/root/client-configsnano client1.ovpn
# Configuration client OpenVPN avec certificats AD CS
client
dev tun
proto udp
# Adresse du serveur VPN (IP WAN de pfSense ou IP publique)
remote 192.168.17.136 1194
# Paramètres de connexion
resolv-retry infinite
nobind
persist-key
persist-tun
# Vérification du certificat serveur
remote-cert-tls server
# Paramètres de sécurité (doivent correspondre au serveur)
cipher AES-256-GCM
auth SHA256
# Niveau de logs
verb 3
# Certificats intégrés
<ca>
</ca>
<cert>
</cert>
<key>
</key>
ca.crt entre <ca> et </ca>client1.crt entre <cert> et </cert>client1.key entre <key> et </key>C:\Users\Administrateur\Documents
client1.ovpn et vous y copierez le contenu du fichier du même nom créer dans le serveur VPN