mirror of
https://github.com/certbot/certbot.git
synced 2026-06-08 16:22:18 -04:00
Trying to standardize JSON terms
This commit is contained in:
parent
2540f1f1e8
commit
182e9b29e4
3 changed files with 11 additions and 8 deletions
|
|
@ -47,7 +47,7 @@ class Config:
|
|||
self.timestamp = parse_timestamp(val)
|
||||
elif atr == "expires":
|
||||
self.expires = parse_timestamp(val)
|
||||
elif atr == "tls-policies":
|
||||
elif atr == "security-policies":
|
||||
self.tls_policies = {}
|
||||
for domain,policies in self.check_tls_policy_domains(val):
|
||||
if type(policies) != dict:
|
||||
|
|
@ -67,18 +67,18 @@ class Config:
|
|||
|
||||
def check_tls_policy_domains(self, val):
|
||||
if type(val) != dict:
|
||||
raise TypeError, "tls-policies should be a dict" + `val`
|
||||
raise TypeError, "security-policies should be a dict" + `val`
|
||||
for domain, policies in val.items():
|
||||
try:
|
||||
assert type(domain) == unicode
|
||||
d = str(domain) # convert from unicode
|
||||
except:
|
||||
raise TypeError, "tls-policy domain not a string" + `domain`
|
||||
raise TypeError, "security-policy domain not a string" + `domain`
|
||||
if not d.startswith("*."):
|
||||
raise ValueError, "tls-policy domains must start with *.; try *."+d
|
||||
raise ValueError, "security-policy domains must start with *.; try *."+d
|
||||
d = d.partition("*.")[2]
|
||||
if not looks_like_a_domain(d):
|
||||
raise ValueError, "tls-policy for something that a domain? " + d
|
||||
raise ValueError, "security-policy for something that a domain? " + d
|
||||
yield (d, policies)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@ class PostfixConfigGenerator(MTAConfigGenerator):
|
|||
self.new_cf += sep + new_cf_lines
|
||||
|
||||
print self.new_cf
|
||||
f = open(self.fn, "w").write(self.new_cf)
|
||||
f = open(self.fn, "w")
|
||||
f.write(self.new_cf)
|
||||
f.close()
|
||||
|
||||
def find_postfix_cf(self):
|
||||
"Search far and wide for the correct postfix configuration file"
|
||||
|
|
@ -121,8 +123,9 @@ class PostfixConfigGenerator(MTAConfigGenerator):
|
|||
|
||||
f = open(DEFAULT_POLICY_FILE, "w")
|
||||
f.write("\n".join(self.policy_lines) + "\n")
|
||||
f.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
import ConfigParser
|
||||
c = ConfigParser.Config()
|
||||
c = ConfigParser.Config("starttls-everywhere.json")
|
||||
pcgen = PostfixConfigGenerator(c, fixup=True)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"timestamp": 1401093333,
|
||||
"author": "Electronic Frontier Foundation https://eff.org",
|
||||
"expires": 1404677353, "comment 2:": "epoch seconds",
|
||||
"tls-policies": {
|
||||
"security-policies": {
|
||||
"*.valid-example-recipient.com": {
|
||||
"min-tls-version": "TLSv1.1"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue