Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
907 connectés 

  FORUM HardWare.fr
  Systèmes & Réseaux Pro
  Sécurité

  [résolu] openvpn : authentification par certificats + user/password

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[résolu] openvpn : authentification par certificats + user/password

n°95926
arn100
Posté le 13-05-2012 à 16:02:51  profilanswer
 

Bonjour à tous,
 
J'ai installé Openvpn avec une authentification forte : certificats pour chaque client + authentification ldap
 
Comment faire pour qu'un client n'utilise pas le certificat d'un autre client? (en s'authentifiant bien avec son propre user/password). Autrement dit, y a t'il, en fait, un moyen pour veiller à ce que le common name du certificat client soit identique au username?
 
Car, pour mes tests, je me suis créé un certificat client, et avec je peux aussi avoir accès au vpn en me connectant avec d'autres username/passwd :-/
 
 
côté serveur :
 


...
common-name-as-username
plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so openvpn


 
côté client :
 

...
ca ca.crt
cert client.crt
key client.key
...
auth-user-pass


 
côté serveur, j'ai pour l'instant mis l'attribut "common-name-as-username" afin d'avoir, dans les log du serveur, le username plutôt que le common name présent dans le certificat du client (bien que l'attribut semble vouloir dire l'inverse)
 
merci de votre aide ;-)
bon dimanche à vous


Message édité par arn100 le 14-05-2012 à 13:43:14
mood
Publicité
Posté le 13-05-2012 à 16:02:51  profilanswer
 

n°95928
Je@nb
Modérateur
Kindly give dime
Posté le 13-05-2012 à 16:37:22  profilanswer
 

Sur PFsense tu as cette option. Elle marche en utilisant un script externe qui est appelée lors du logon via auth-user-pass-verify
Ce script vérifie (entre autres) que le username = le comonname.
http://redmine.pfsense.org/project [...] 6e3a259a8c

n°95932
arn100
Posté le 13-05-2012 à 18:51:58  profilanswer
 

merci, c'est vrai que ce script fait a priori bien ce que je voudrais faire :-)
 
par contre il est très lié à pfsense visiblement... donc difficilement utilisable pour moi :-/  
 
J'utilise openvpn 2.0 sous linux debian squeeze

n°95933
Je@nb
Modérateur
Kindly give dime
Posté le 13-05-2012 à 19:10:15  profilanswer
 

Non mais adaptable par contre il l'est, ou tu peux en faire un qui colle à ton besoin

n°95942
arn100
Posté le 13-05-2012 à 21:43:50  profilanswer
 

Je@nb a écrit :

Non mais adaptable par contre il l'est, ou tu peux en faire un qui colle à ton besoin

 


Dans la doc d'openvpn (http://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html)

 

je me rends compte qu'on peut avoir accès à un certain nombre de variables (dont common-name et username) en scriptant et en utilisant l'attribut "auth-user-pass-verify" :

 


Environmental Variables
Once set, a variable is persisted indefinitely until it is reset by a new value or a restart,

 

As of OpenVPN 2.0-beta12, in server mode, environmental variables set by OpenVPN are scoped according to the client objects they are associated with, so there should not be any issues with scripts having access to stale, previously set variables which refer to different client instances.

 

bytes_received
    Total number of bytes received from client during VPN session. Set prior to execution of the --client-disconnect script.
bytes_sent
    Total number of bytes sent to client during VPN session. Set prior to execution of the --client-disconnect script.
common_name
    The X509 common name of an authenticated client. Set prior to execution of --client-connect, --client-disconnect, and --auth-user-pass-verify scripts.
config
    Name of first --config file. Set on program initiation and reset on SIGHUP.
..
username
    The username provided by a connecting client. Set prior to --auth-user-pass-verify script execution only when the via-env modifier is specified.

 


sais-tu si je peux utiliser le plugin pam qui marche très bien... et faire, en plus, un script de vérification avec "auth-user-pass-verify" ?

 

mon server.conf serait du genre :


...
common-name-as-username
plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so openvpn
auth-user-pass-verify mon-script-bash-de-verif.sh via-env

 

a priori je ne pense pas....( que ce soit possible d'utiliser le plugin + auth-user-pass-verify)

 


mais je ne souhaite pas mettre un script-security level à 3 et n'utiliser que auth-user-pass-verify...

 


--script-security level [method]
              This  directive offers policy-level control over OpenVPN’s usage
              of external programs and scripts.  Lower level values  are  more
              restrictive,  higher  values  are more permissive.  Settings for
              level:

 

             0 -- Strictly no calling of external programs.
              1 -- (Default) Only call built-in executables such as  ifconfig,
              ip, route, or netsh.
              2  --  Allow  calling  of  built-in executables and user-defined
              scripts.
              3 -- Allow passwords to be passed to scripts  via  environmental
              variables (potentially unsafe).



Message édité par arn100 le 13-05-2012 à 21:46:03
n°95944
Je@nb
Modérateur
Kindly give dime
Posté le 13-05-2012 à 21:49:43  profilanswer
 

D'après la doc :

--plugin module-pathname [init-string]
    Load plug-in module from the file module-pathname, passing init-string as an argument to the module initialization function. Multiple plugin modules may be loaded into one OpenVPN process.
 
    For more information and examples on how to build OpenVPN plug-in modules, see the README file in the plugin folder of the OpenVPN source distribution.
 
    If you are using an RPM install of OpenVPN, see /usr/share/openvpn/plugin. The documentation is in doc and the actual plugin modules are in lib.
 
    Multiple plugin modules can be cascaded, and modules can be used in tandem with scripts. The modules will be called by OpenVPN in the order that they are declared in the config file. If both a plugin and script are configured for the same callback, the script will be called last. If the return code of the module/script controls an authentication function (such as tls-verify, auth-user-pass-verify, or client-connect), then every module and script must return success (0) in order for the connection to be authenticated.


 
Tu devrais pouvoir cumuler les 2.
Pour la sécu, tu peux essayer à 2 vu que tu t'en fous du mot de passe.
Essaie tu verras bien ^^

n°95946
arn100
Posté le 13-05-2012 à 22:15:54  profilanswer
 

ça à l'air faisable :-)
 
effectivement je peux mettre le level à 2 puisque je n'ai pas besoin de checker le pwd  
 
merci!
j'essaie demain!

n°95957
arn100
Posté le 14-05-2012 à 11:36:54  profilanswer
 

arn100 a écrit :

ça à l'air faisable :-)
 
effectivement je peux mettre le level à 2 puisque je n'ai pas besoin de checker le pwd  
 
merci!
j'essaie demain!


 
nickel ça marche...
 
server.conf :


..
username-as-common-name
plugin /usr/lib/openvpn/openvpn-auth-pam.so openvpn
script-security 2
auth-user-pass-verify /etc/openvpn/verif-cn-username.sh via-env


 
/etc/openvpn/verif-cn-username.sh :


#!/bin/sh
if [ "$username" -ne "$common_name" ]
    then
        exit 0
fi


 
merci :-)


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Systèmes & Réseaux Pro
  Sécurité

  [résolu] openvpn : authentification par certificats + user/password

 

Sujets relatifs
Gpo d'authentification au reseau grace au domaineavantages et inconvénients authentification wifi (: PSK, portail capti
Proxy SQUID avec authentification ADProxy SQUID avec authentification AD
[W2008] Gestion des certificats Bureau à distance sans ADproblème authentification radius
Freeradius - Problème d'authentification wifiSolutions de sécurité wifi ( authentification)
Certificats Remote DesktopPousser l'authentification Squid-LDAP
Plus de sujets relatifs à : [résolu] openvpn : authentification par certificats + user/password


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR