@@ -1027,6 +1027,9 @@ class HTTP_Server(Automaton):
1027
1027
1028
1028
:param ssp: the SSP to serve. If None, unauthenticated (or basic).
1029
1029
:param mech: the HTTP_AUTH_MECHS to use (default: NONE)
1030
+ :param require_cbt: require Channel Bindings to be valid (default: False)
1031
+ :param cbt_cert: the path to the certificate used for channel bindings.
1032
+ Useful if behind a reverse proxy. (default: None)
1030
1033
1031
1034
Other parameters:
1032
1035
@@ -1042,6 +1045,8 @@ def __init__(
1042
1045
mech = HTTP_AUTH_MECHS .NONE ,
1043
1046
verb = True ,
1044
1047
ssp = None ,
1048
+ require_cbt : bool = False ,
1049
+ cbt_cert : str = None ,
1045
1050
* args ,
1046
1051
** kwargs ,
1047
1052
):
@@ -1053,8 +1058,20 @@ def __init__(
1053
1058
self .ssp = ssp
1054
1059
self .authmethod = mech .value
1055
1060
self .sspcontext = None
1061
+
1062
+ # CBT settings
1056
1063
self .ssp_req_flags = GSS_S_FLAGS .GSS_S_ALLOW_MISSING_BINDINGS
1057
- self .chan_bindings = GSS_C_NO_CHANNEL_BINDINGS
1064
+ if require_cbt :
1065
+ self .ssp_req_flags &= ~ GSS_S_FLAGS .GSS_S_ALLOW_MISSING_BINDINGS
1066
+ if cbt_cert :
1067
+ self .chan_bindings = GssChannelBindings .fromssl (
1068
+ ChannelBindingType .TLS_SERVER_END_POINT ,
1069
+ certfile = cbt_cert ,
1070
+ )
1071
+ else :
1072
+ self .chan_bindings = GSS_C_NO_CHANNEL_BINDINGS
1073
+
1074
+ # Auth settings
1058
1075
self .basic = False
1059
1076
self .BASIC_IDENTITIES = kwargs .pop ("BASIC_IDENTITIES" , {})
1060
1077
self .BASIC_REALM = kwargs .pop ("BASIC_REALM" , "default" )
@@ -1311,16 +1328,8 @@ def __init__(
1311
1328
mech = mech ,
1312
1329
verb = verb ,
1313
1330
ssp = ssp ,
1331
+ cbt_cert = cert ,
1332
+ require_cbt = require_cbt ,
1314
1333
* args ,
1315
1334
** kwargs ,
1316
1335
)
1317
-
1318
- # Set channel binding
1319
- if cert :
1320
- self .chan_bindings = GssChannelBindings .fromssl (
1321
- ChannelBindingType .TLS_SERVER_END_POINT ,
1322
- certfile = cert ,
1323
- )
1324
- if require_cbt :
1325
- # We require CBT by removing GSS_S_ALLOW_MISSING_BINDINGS
1326
- self .ssp_req_flags &= ~ GSS_S_FLAGS .GSS_S_ALLOW_MISSING_BINDINGS
0 commit comments