Skip to content

Commit ae471d3

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

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

data/templates/ocserv/ocserv_config.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ auth = "plain[otp=/run/ocserv/users.oath]"
3030
{% else %}
3131
auth = "plain[/run/ocserv/ocpasswd]"
3232
{% endif %}
33+
{% elif "cert" in authentication.mode %}
34+
auth = "certificate"
35+
cert-user-oid = {{ authentication.mode.cert }}
3336
{% else %}
3437
auth = "plain[/run/ocserv/ocpasswd]"
3538
{% 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="cert">
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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,21 @@ def verify(ocserv):
106106
if (
107107
'local' in ocserv['authentication']['mode']
108108
and 'radius' in ocserv['authentication']['mode']
109+
or
110+
'local' in ocserv['authentication']['mode']
111+
and 'cert' in ocserv['authentication']['mode']
112+
or
113+
'radius' in ocserv['authentication']['mode']
114+
and 'cert' 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 cert.'
112118
)
119+
if 'cert' in ocserv['authentication']['mode']:
120+
if 'cn' in ocserv['authentication']['mode']['cert']:
121+
ocserv['authentication']['mode']['cert'] = '2.5.4.3'
122+
elif 'uid' in ocserv['authentication']['mode']['cert']:
123+
ocserv['authentication']['mode']['cert'] = '0.9.2342.19200300.100.1.1'
113124
if 'radius' in ocserv['authentication']['mode']:
114125
if 'server' not in ocserv['authentication']['radius']:
115126
raise ConfigError(
@@ -202,6 +213,9 @@ def verify(ocserv):
202213
raise ConfigError('SSL certificate missing on OpenConnect config!')
203214
verify_pki_certificate(ocserv, ocserv['ssl']['certificate'])
204215

216+
if 'ca_certificate' not in ocserv['ssl'] and 'cert' in ocserv['authentication']['mode']:
217+
raise ConfigError('CA certificate must be provided in certificate authentication mode!')
218+
205219
if 'ca_certificate' in ocserv['ssl']:
206220
for ca_cert in ocserv['ssl']['ca_certificate']:
207221
verify_pki_ca_certificate(ocserv, ca_cert)

0 commit comments

Comments
 (0)