ssl_config_parser: refactor for sanity reasons
This commit is contained in:
parent
3d4d3f4ac2
commit
1715935846
1 changed files with 17 additions and 15 deletions
|
|
@ -13,14 +13,6 @@ const
|
||||||
ConfigSource = "https://ssl-config.mozilla.org/guidelines/latest.json"
|
ConfigSource = "https://ssl-config.mozilla.org/guidelines/latest.json"
|
||||||
OutputFile = "ssl_config.nim"
|
OutputFile = "ssl_config.nim"
|
||||||
|
|
||||||
func appendToList(list, str: string): string =
|
|
||||||
if list.len == 0:
|
|
||||||
result = str
|
|
||||||
elif str.len == 0:
|
|
||||||
result = list
|
|
||||||
else:
|
|
||||||
result = list & ':' & str
|
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
let
|
let
|
||||||
client = newHttpClient(sslContext = newContext(verifyMode = CVerifyPeer))
|
client = newHttpClient(sslContext = newContext(verifyMode = CVerifyPeer))
|
||||||
|
|
@ -46,17 +38,27 @@ proc main() =
|
||||||
for name, config in configs["configurations"]:
|
for name, config in configs["configurations"]:
|
||||||
let
|
let
|
||||||
constantName = "Ciphers" & name[0].toUpperAscii & name[1..^1]
|
constantName = "Ciphers" & name[0].toUpperAscii & name[1..^1]
|
||||||
ciphers = config["ciphersuites"].foldl(a.appendToList b.getStr, "").appendToList(
|
|
||||||
config["ciphers"]["openssl"].foldl(a.appendToList b.getStr, "")
|
|
||||||
)
|
|
||||||
oldestClients = config["oldest_clients"].foldl(a & "\n ## * " & b.getStr, "")
|
|
||||||
|
|
||||||
output.writeLine(&"""
|
var ciphers: string
|
||||||
|
for c in config["ciphersuites"].getElems & config["ciphers"]["openssl"].getElems:
|
||||||
|
if ciphers.len == 0:
|
||||||
|
ciphers.add c.getStr
|
||||||
|
else:
|
||||||
|
ciphers.add ':'
|
||||||
|
ciphers.add c.getStr
|
||||||
|
|
||||||
|
var constant = &"""
|
||||||
const {constantName}* = "{ciphers}"
|
const {constantName}* = "{ciphers}"
|
||||||
## An OpenSSL-compatible list of secure ciphers for ``{name}`` compatibility
|
## An OpenSSL-compatible list of secure ciphers for ``{name}`` compatibility
|
||||||
## per Mozilla's recommendations.
|
## per Mozilla's recommendations.
|
||||||
##
|
##
|
||||||
## Oldest clients supported by this list:{oldestClients}
|
## Oldest clients supported by this list:
|
||||||
""")
|
"""
|
||||||
|
|
||||||
|
for c in config["oldest_clients"]:
|
||||||
|
constant.add " ## * " & c.getStr
|
||||||
|
constant.add '\n'
|
||||||
|
|
||||||
|
output.writeLine constant
|
||||||
|
|
||||||
when isMainModule: main()
|
when isMainModule: main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue