Skip to content

Commit e451137

Browse files
cli: pin the SCEP GetCACert response
- --ca-fingerprint takes [sha256:|sha1:|sha512:]HEX. parse_ca_fingerprint decodes it into a CaPin, ignoring ':' and ' ' between hex digits, and refuses malformed hex, an unnamed digest, a length that disagrees with the named digest, and a digest wolfSSL was not built with. scep_pin_setup resolves it for the SCEP commands and, when it is absent, notes that the served CA is trusted unverified. check_proto_only_opts refuses the option under EST. - pem_cert_at converts the idx-th PEM certificate of a GetCACert response to DER, find_pinned_cert returns the one matching the pin, and print_ca_fingerprints writes each certificate's SHA-256 to stderr. - scep_enroll carries the SCEP arm of cmd_enroll. With a pin the matched certificate is the envelope recipient and the only CertRep trust anchor and the bundle is not fetched; unpinned, the bundle remains the trust set. cmd_getcacerts reports the fingerprints and fails on a pin that matches nothing, and cmd_getnextca resolves the current CA from the pinned certificate. - cli_proto_scoping.sh covers the scoping and the argument rejections, and starts wolfcert-server for a group that reads the fingerprint from getcacerts, then runs enroll and getnextca with a mismatched and a matching pin. - README.md documents fetching and pinning the fingerprint; docs/MIGRATING-FROM-WOLFSCEP.md names the flag beside the API. Issue: F-8046
1 parent c124b6f commit e451137

4 files changed

Lines changed: 623 additions & 96 deletions

File tree

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ The CLI also covers TLS / mutual TLS (`--trust`, `--client-cert`,
108108
`--client-key`), TLS 1.3 post-handshake auth (`--pha`), SCEP polling
109109
(`--poll-attempts`, `--poll-interval-ms`), `getnextca`, and `/csrattrs`
110110
key-policy pinning (`--csrattrs-auto`). The SCEP-specific knobs are
111-
`--ca-id` (select one CA on a multi-CA responder), `--txid-mode` (`random`
112-
or `pubkey`, the RFC 8894 §3.2.1 public-key derivation) and
113-
`--content-cipher` (`auto`, `aes128`, `aes256`, `des3` - force one for a
114-
peer that requires it, since no GetCACaps keyword advertises AES-256).
111+
`--ca-fingerprint` (see below), `--ca-id` (select one CA on a multi-CA
112+
responder), `--txid-mode` (`random` or `pubkey`, the RFC 8894 §3.2.1
113+
public-key derivation) and `--content-cipher` (`auto`, `aes128`, `aes256`,
114+
`des3` - force one for a peer that requires it, since no GetCACaps keyword
115+
advertises AES-256).
115116
Options that belong to one protocol are rejected under the other rather
116117
than silently ignored. Run `wolfcert-client --help` and
117118
`wolfcert-server --help` for the full set.
@@ -120,6 +121,34 @@ EST mandates authenticating the server (RFC 7030), so an EST enroll needs
120121
`--trust PEMFILE` (or a caller-supplied trust anchor). Without it the client
121122
refuses rather than hand its credentials and CSR to an unverified server.
122123

124+
SCEP instead authenticates the CA by fingerprint. Whoever answers `GetCACert`
125+
becomes both the recipient that decrypts your CSR (and its
126+
`challengePassword`) and the trust anchor for the certificate you are handed
127+
back, so pin it. Read the fingerprint once over a path you trust:
128+
129+
```sh
130+
./wolfcert-client getcacerts --proto scep --url http://127.0.0.1:8088/scep \
131+
--out-cert ca.pem
132+
# getcacerts: certificate 0 is sha256:3F:A1:...
133+
```
134+
135+
then require it on every later run:
136+
137+
```sh
138+
./wolfcert-client enroll --proto scep --url http://127.0.0.1:8088/scep \
139+
--ca-fingerprint sha256:3F:A1:... \
140+
--key-type rsa:2048 --subject "CN=device-2" \
141+
--out-key dev.key --out-cert dev.crt
142+
```
143+
144+
Only the certificate matching the fingerprint is used, as the envelope
145+
recipient and as the sole trust anchor for the reply; anything else the
146+
server sends alongside it is ignored. A response with no match is refused.
147+
Without the flag the client warns and trusts whatever it is served, which is
148+
fine against a test server and not fine anywhere else. A CA that answers
149+
`GetCACert` with a separate registration authority needs that RA's
150+
fingerprint, since the RA is what signs the reply.
151+
123152
To call the library directly, see `examples/enroll_est.c`,
124153
`examples/enroll_scep.c`, and `examples/enroll_cryptocb.c`.
125154

0 commit comments

Comments
 (0)