Skip to content

Commit e3c0aa9

Browse files
committed
T7635: OpenConnect Certificate Authentication
1 parent 135c2d3 commit e3c0aa9

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

data/templates/ocserv/ocserv_config.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ auth = "plain[otp=/run/ocserv/users.oath]"
3030
{% else %}
3131
auth = "plain[/run/ocserv/ocpasswd]"
3232
{% endif %}
33+
{% elif "certificate" in authentication.mode %}
34+
auth = "certificate"
35+
{% if authentication.mode.certificate == "cn" %}
36+
cert-user-oid = 2.5.4.3
37+
{% elif authentication.mode.certificate == "uid" %}
38+
cert-user-oid = 0.9.2342.19200300.100.1.1
39+
{% else %}
40+
cert-user-oid = {{ authentication.mode.certificate }}
41+
{% endif %}
3342
{% else %}
3443
auth = "plain[/run/ocserv/ocpasswd]"
3544
{% endif %}

interface-definitions/vpn_openconnect.xml.in

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@
6969
<valueless/>
7070
</properties>
7171
</leafNode>
72+
<leafNode name="certificate">
73+
<properties>
74+
<help>Use certificate based authentication</help>
75+
<valueHelp>
76+
<format>cn</format>
77+
<description>OID 2.5.4.3 - Common Name</description>
78+
</valueHelp>
79+
<valueHelp>
80+
<format>uid</format>
81+
<description>OID 0.9.2342.19200300.100.1.1 - UID</description>
82+
</valueHelp>
83+
<valueHelp>
84+
<format>x.x.xx.xxx</format>
85+
<description>Custom OID in dotted decimal format</description>
86+
</valueHelp>
87+
<constraint>
88+
<regex>(^\d{1,5}(?:\.\d{1,5})*$|cn|uid)</regex>
89+
</constraint>
90+
<constraintErrorMessage>Invalid OID selection. Must be cn, uid, or a valid OID format.</constraintErrorMessage>
91+
<completionHelp>
92+
<list>cn uid x.x.xx.xxx</list>
93+
</completionHelp>
94+
</properties>
95+
</leafNode>
7296
</children>
7397
</node>
7498
<node name="identity-based-config">

src/conf_mode/vpn_openconnect.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,17 @@ def verify(ocserv):
104104
if 'authentication' in ocserv:
105105
if 'mode' in ocserv['authentication']:
106106
if (
107-
'local' in ocserv['authentication']['mode']
108-
and 'radius' in ocserv['authentication']['mode']
107+
('local' in ocserv['authentication']['mode']
108+
and 'radius' in ocserv['authentication']['mode'])
109+
or
110+
('local' in ocserv['authentication']['mode']
111+
and 'certificate' in ocserv['authentication']['mode'])
112+
or
113+
('radius' in ocserv['authentication']['mode']
114+
and 'certificate' in ocserv['authentication']['mode'])
109115
):
110116
raise ConfigError(
111-
'OpenConnect authentication modes are mutually-exclusive, remove either local or radius from your configuration'
117+
'OpenConnect authentication modes are mutually-exclusive. Only one of local, radius, or certificate.'
112118
)
113119
if 'radius' in ocserv['authentication']['mode']:
114120
if 'server' not in ocserv['authentication']['radius']:
@@ -202,6 +208,9 @@ def verify(ocserv):
202208
raise ConfigError('SSL certificate missing on OpenConnect config!')
203209
verify_pki_certificate(ocserv, ocserv['ssl']['certificate'])
204210

211+
if 'ca_certificate' not in ocserv['ssl'] and 'certificiate' in ocserv['authentication']['mode']:
212+
raise ConfigError('CA certificate must be provided in certificate authentication mode!')
213+
205214
if 'ca_certificate' in ocserv['ssl']:
206215
for ca_cert in ocserv['ssl']['ca_certificate']:
207216
verify_pki_ca_certificate(ocserv, ca_cert)

0 commit comments

Comments
 (0)