@@ -26,15 +26,94 @@ def __repr__(self):
26
26
def install (self ):
27
27
self .env .install_test_conf (self ._lines )
28
28
29
+ def replacetlsstr (self , line ):
30
+ l = line .replace ("TLS_" , "" )
31
+ l = l .replace ("\n " , " " )
32
+ l = l .replace ("\\ " , " " )
33
+ l = " " .join (l .split ())
34
+ l = l .replace (" " , ":" )
35
+ l = l .replace ("_" , "-" )
36
+ l = l .replace ("-WITH" , "" )
37
+ l = l .replace ("AES-" , "AES" )
38
+ l = l .replace ("POLY1305-SHA256" , "POLY1305" )
39
+ return l
40
+
41
+ def replaceinstr (self , line ):
42
+ if line .startswith ("TLSCiphersPrefer" ):
43
+ # the "TLS_" are changed into "".
44
+ l = self .replacetlsstr (line )
45
+ l = l .replace ("TLSCiphersPrefer:" , "SSLCipherSuite " )
46
+ elif line .startswith ("TLSCiphersSuppress" ):
47
+ # like SSLCipherSuite but with :!
48
+ l = self .replacetlsstr (line )
49
+ l = l .replace ("TLSCiphersSuppress:" , "SSLCipherSuite !" )
50
+ l = l .replace (":" , ":!" )
51
+ elif line .startswith ("TLSCertificate" ):
52
+ l = line .replace ("TLSCertificate" , "SSLCertificateFile" )
53
+ elif line .startswith ("TLSProtocol" ):
54
+ # mod_ssl is different (+ no supported and 0x code have to be translated)
55
+ l = line .replace ("TLSProtocol" , "SSLProtocol" )
56
+ l = l .replace ("+" , "" )
57
+ l = l .replace ("default" , "all" )
58
+ l = l .replace ("0x0303" , "1.3" ) # need to check 1.2 and 1.1
59
+ elif line .startswith ("TLSHonorClientOrder" ):
60
+ # mod_ssl has SSLHonorCipherOrder on = use server off = use client.
61
+ l = line .lower ()
62
+ if "on" in l :
63
+ l = "SSLHonorCipherOrder off"
64
+ else :
65
+ l = "SSLHonorCipherOrder on"
66
+ elif line .startswith ("TLSEngine" ):
67
+ # In fact it should go in the corresponding VirtualHost... Not sure how to do that.
68
+ l = "SSLEngine On"
69
+ else :
70
+ if line != "" :
71
+ l = line .replace ("TLS" , "SSL" )
72
+ else :
73
+ l = line
74
+ return l
75
+
29
76
def add (self , line : Any ):
77
+ # make we transform the TLS to SSL if we are using mod_ssl
30
78
if isinstance (line , str ):
79
+ if not HttpdTestEnv .has_shared_module ("tls" ):
80
+ line = self .replaceinstr (line )
31
81
if self ._indents > 0 :
32
82
line = f"{ ' ' * self ._indents } { line } "
33
83
self ._lines .append (line )
34
84
else :
35
- if self ._indents > 0 :
36
- line = [f"{ ' ' * self ._indents } { l } " for l in line ]
37
- self ._lines .extend (line )
85
+ if not HttpdTestEnv .has_shared_module ("tls" ):
86
+ new = []
87
+ previous = ""
88
+ for l in line :
89
+ if previous .startswith ("SSLCipherSuite" ):
90
+ if l .startswith ("TLSCiphersPrefer" ) or l .startswith ("TLSCiphersSuppress" ):
91
+ # we need to merge it
92
+ l = self .replaceinstr (l )
93
+ l = l .replace ("SSLCipherSuite " , ":" )
94
+ previous = previous + l
95
+ continue
96
+ else :
97
+ if self ._indents > 0 :
98
+ previous = f"{ ' ' * self ._indents } { previous } "
99
+ new .append (previous )
100
+ previous = ""
101
+ l = self .replaceinstr (l )
102
+ if l .startswith ("SSLCipherSuite" ):
103
+ previous = l
104
+ continue
105
+ if self ._indents > 0 :
106
+ l = f"{ ' ' * self ._indents } { l } "
107
+ new .append (l )
108
+ if previous != "" :
109
+ if self ._indents > 0 :
110
+ previous = f"{ ' ' * self ._indents } { previous } "
111
+ new .append (previous )
112
+ self ._lines .extend (new )
113
+ else :
114
+ if self ._indents > 0 :
115
+ line = [f"{ ' ' * self ._indents } { l } " for l in line ]
116
+ self ._lines .extend (line )
38
117
return self
39
118
40
119
def add_certificate (self , cert_file , key_file , ssl_module = None ):
0 commit comments