首页 > ocserv: 如何识别正在连接的用户信息?

ocserv: 如何识别正在连接的用户信息?

我用 ocserv 搭建了一个 AnyConnect 服务器,用的是 certificate 验证模式,我想对每个用户做流量统计。

我从样例配置文件里面知道 ocserv 支持 connect-script ,并且会把 REASON, USERNAME, GROUPNAME, HOSTNAME, DEVICE, IP_REAL, IP_LOCAL, IP_REMOTE 作为变量传递给脚本。但问题是,我写了一个脚本把以上变量打印出来,结果 USERNAME, GROUPNAME, HOSTNAME 是空的,这样就无法识别用户了。

所以应该怎么解决呢?


The certificate need also contain user identifying information, for example, the user ID of the client must be embedded in the certificate’s Distinguished Name (DN), i.e., in the Common Name, or UID fields. For the server to read the name, the cert-user-oid configuration option must be set.

使用证书验证的时候,ocserv根据cert-user-oidcert-group-oid选项寻找证书对应的区域来确定USERNAMEGROUPNAME

比如我客户端证书中是这么写的:

CN=VPNUser
UNIT=Group A

ocserv.conf里需要启用下面的设置(默认是被注释掉的):

cert-user-oid = 2.5.4.3
cert-group-oid = 2.5.4.11

ocserv.conf在这两个选项的上面有详尽的注释,也指出了常用的区域,比如CN2.5.4.3UNIT(OU/organizational unit)2.5.4.11

【热门文章】
【热门文章】