Skip to content

Commit b4cbe76

Browse files
authored
Merge pull request #1704 from drwetter/add_ca_dir
Allow dir with PEM files for --add-CA
2 parents 565c93e + ecc6cd8 commit b4cbe76

5 files changed

Lines changed: 14 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Rating (SSL Labs, not complete)
2121
* Don't penalize missing trust in rating when CA not in Java store
2222
* Added support for certificates with EdDSA signatures and pubilc keys
23+
* --add-ca can also now be a directory with \*.pem files
2324

2425
### Features implemented / improvements in 3.0
2526

doc/testssl.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Please note that \fBfname\fR has to be in Unix format\. DOS carriage returns won
179179
\fB\-\-phone\-out\fR Checking for revoked certificates via CRL and OCSP is not done per default\. This switch instructs testssl\.sh to query external \-\- in a sense of the current run \-\- URIs\. By using this switch you acknowledge that the check might have privacy issues, a download of several megabytes (CRL file) may happen and there may be network connectivity problems while contacting the endpoint which testssl\.sh doesn\'t handle\. PHONE_OUT is the environment variable for this which needs to be set to true if you want this\.
180180
.
181181
.P
182-
\fB\-\-add\-ca <cafile>\fR enables you to add your own CA(s) for trust chain checks\. \fBcafile\fR can be a single path or multiple paths as a comma separated list of root CA files\. Internally they will be added during runtime to all CA stores\. This is (only) useful for internal hosts whose certificates is issued by internal CAs\. Alternatively ADDTL_CA_FILES is the environment variable for this\.
182+
\fB\-\-add\-ca <CAfile>\fR enables you to add your own CA(s) in PEM format for trust chain checks\. \fBCAfile\fR can be a directory containing files with a \.pem extension, a single file or multiple files as a comma separated list of root CAs\. Internally they will be added during runtime to all CA stores\. This is (only) useful for internal hosts whose certificates are issued by internal CAs\. Alternatively ADDTL_CA_FILES is the environment variable for this\.
183183
.
184184
.SS "SINGLE CHECK OPTIONS"
185185
Any single check switch supplied as an argument prevents testssl\.sh from doing a default run\. It just takes this and if supplied other options and runs them \- in the order they would also appear in the default run\.

doc/testssl.1.html

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/testssl.1.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ in `/etc/hosts`. The use of the switch is only useful if you either can't or ar
145145

146146
`--phone-out` Checking for revoked certificates via CRL and OCSP is not done per default. This switch instructs testssl.sh to query external -- in a sense of the current run -- URIs. By using this switch you acknowledge that the check might have privacy issues, a download of several megabytes (CRL file) may happen and there may be network connectivity problems while contacting the endpoint which testssl.sh doesn't handle. PHONE_OUT is the environment variable for this which needs to be set to true if you want this.
147147

148-
`--add-ca <cafile>` enables you to add your own CA(s) for trust chain checks. `cafile` can be a single path or multiple paths as a comma separated list of root CA files. Internally they will be added during runtime to all CA stores. This is (only) useful for internal hosts whose certificates is issued by internal CAs. Alternatively ADDTL_CA_FILES is the environment variable for this.
149-
148+
`--add-ca <CAfile>` enables you to add your own CA(s) in PEM format for trust chain checks. `CAfile` can be a directory containing files with a \.pem extension, a single file or multiple files as a comma separated list of root CAs. Internally they will be added during runtime to all CA stores. This is (only) useful for internal hosts whose certificates are issued by internal CAs. Alternatively ADDTL_CA_FILES is the environment variable for this.
149+
.
150+
.SS "SINGLE CHECK OPTIONS"
150151

151152
### SINGLE CHECK OPTIONS
152153

testssl.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18882,7 +18882,7 @@ tuning / connect options (most also can be preset via environment variables):
1888218882
--sneaky leave less traces in target logs: user agent, referer
1888318883
--ids-friendly skips a few vulnerability checks which may cause IDSs to block the scanning IP
1888418884
--phone-out allow to contact external servers for CRL download and querying OCSP responder
18885-
--add-ca <cafile> path to <cafile> or a comma separated list of CA files enables test against additional CAs.
18885+
--add-ca <CA files|CA dir> path to <CAdir> with *.pem or a comma separated list of CA files to include in trust check
1888618886
--basicauth <user:pass> provide HTTP basic auth information.
1888718887

1888818888
output options (can also be preset via environment variables):
@@ -21844,7 +21844,11 @@ parse_cmd_line() {
2184421844
"$do_mx_all_ips" && [[ "$NODNS" == none ]] && fatal "\"--mx\" and \"--nodns=none\" don't work together" $ERR_CMDLINE
2184521845
[[ -n "$CONNECT_TIMEOUT" ]] && [[ "$MASS_TESTING_MODE" == parallel ]] && fatal "Parallel mass scanning and specifying connect timeouts currently don't work together" $ERR_CMDLINE
2184621846

21847-
ADDTL_CA_FILES="${ADDTL_CA_FILES//,/ }"
21847+
if [[ -d $ADDTL_CA_FILES ]]; then
21848+
ADDTL_CA_FILES="$ADDTL_CA_FILES/*.pem"
21849+
else
21850+
ADDTL_CA_FILES="${ADDTL_CA_FILES//,/ }"
21851+
fi
2184821852
for fname in $ADDTL_CA_FILES; do
2184921853
[[ -s "$fname" ]] || fatal "CA file \"$fname\" does not exist" $ERR_RESOURCE
2185021854
grep -q "BEGIN CERTIFICATE" "$fname" || fatal "\"$fname\" is not CA file in PEM format" $ERR_RESOURCE

0 commit comments

Comments
 (0)