ssl_certs: add Haiku support (#13761)
This commit is contained in:
parent
2da438c33b
commit
6162da812a
1 changed files with 32 additions and 7 deletions
|
|
@ -49,6 +49,18 @@ const certificate_paths = [
|
||||||
"/etc/openssl/certs",
|
"/etc/openssl/certs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
when defined(haiku):
|
||||||
|
const
|
||||||
|
B_FIND_PATH_EXISTING_ONLY = 0x4
|
||||||
|
B_FIND_PATH_DATA_DIRECTORY = 6
|
||||||
|
|
||||||
|
proc find_paths_etc(architecture: cstring, baseDirectory: cint,
|
||||||
|
subPath: cstring, flags: uint32,
|
||||||
|
paths: var ptr UncheckedArray[cstring],
|
||||||
|
pathCount: var csize): int32
|
||||||
|
{.importc, header: "<FindDirectory.h>".}
|
||||||
|
proc free(p: pointer) {.importc, header: "<stdlib.h>".}
|
||||||
|
|
||||||
iterator scanSSLCertificates*(useEnvVars = false): string =
|
iterator scanSSLCertificates*(useEnvVars = false): string =
|
||||||
## Scan for SSL/TLS CA certificates on disk.
|
## Scan for SSL/TLS CA certificates on disk.
|
||||||
##
|
##
|
||||||
|
|
@ -64,6 +76,7 @@ iterator scanSSLCertificates*(useEnvVars = false): string =
|
||||||
yield fn
|
yield fn
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
when not defined(haiku):
|
||||||
for p in certificate_paths:
|
for p in certificate_paths:
|
||||||
if p.endsWith(".pem") or p.endsWith(".crt"):
|
if p.endsWith(".pem") or p.endsWith(".crt"):
|
||||||
if existsFile(p):
|
if existsFile(p):
|
||||||
|
|
@ -71,6 +84,18 @@ iterator scanSSLCertificates*(useEnvVars = false): string =
|
||||||
elif existsDir(p):
|
elif existsDir(p):
|
||||||
for fn in joinPath(p, "*").walkFiles():
|
for fn in joinPath(p, "*").walkFiles():
|
||||||
yield fn
|
yield fn
|
||||||
|
else:
|
||||||
|
var
|
||||||
|
paths: ptr UncheckedArray[cstring]
|
||||||
|
size: csize
|
||||||
|
let err = find_paths_etc(
|
||||||
|
nil, B_FIND_PATH_DATA_DIRECTORY, "ssl/CARootCertificates.pem",
|
||||||
|
B_FIND_PATH_EXISTING_ONLY, paths, size
|
||||||
|
)
|
||||||
|
if err == 0:
|
||||||
|
defer: free(paths)
|
||||||
|
for i in 0 ..< size:
|
||||||
|
yield $paths[i]
|
||||||
|
|
||||||
# Certificates management on windows
|
# Certificates management on windows
|
||||||
# when defined(windows) or defined(nimdoc):
|
# when defined(windows) or defined(nimdoc):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue