Skip to content

Commit 9352ff2

Browse files
committed
STIR-SHAKEN: Additional config params and more certificate info
1 parent 3384e9b commit 9352ff2

File tree

2 files changed

+197
-476
lines changed

2 files changed

+197
-476
lines changed

docs/Deployment/STIR-SHAKEN/index.md

Lines changed: 197 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ Although [RFC-8226 section 9](https://www.rfc-editor.org/rfc/rfc8226#section-9)
6565
shall contain a single SPC value.". Asterisk therefore will fail to verify a certificate whose TNAuthList extension contains something other than an SPC code.
6666

6767
It was apparently envisioned that a facility would be made available to verify that a particular SPC has the authority over a particular telephone number. To our knowledge, that facility doesn't yet exist. This means that there is currently no way for Asterisk to verify that the SPC in the certificate has the authority over the TN in the Identity header.
68-
6968
///
69+
7070
## Asterisk Implementation
7171

7272
### Configuration
7373

74-
All configuration is done via the stir_shaken.conf file. The sample [stir_shaken.conf](stir_shaken.conf) is heavily commented.
74+
All configuration is done via the stir_shaken.conf file. The sample [stir_shaken.conf](https://github.com/asterisk/asterisk/raw/master/configs/samples/stir_shaken.conf.sample) is heavily commented.
7575

7676
There are 4 object types used by the STIR/SHAKEN process...
7777

@@ -279,38 +279,84 @@ CA certififcate to you separately.
279279
Default: no
280280

281281
##### ca_file
282-
Path to a single file containing a CA certificate or certificate chain
283-
to be used to validate the certificates in incoming requests.
282+
Path to a file containing one or more CA certs in PEM format.
283+
These certs are used to verify the chain of trust for the
284+
certificate retrieved from the X5U Identity header parameter. This
285+
file must have the root CA certificate, the certificate of the
286+
issuer of the X5U certificate, and any intermediate certificates
287+
between them.
284288

285289
Default: none
290+
See Also: [Certificate and CRL Notes](#certificate-and-crl-notes) below
286291

287292
##### ca_path
288-
Path to a directory containing one or more CA certificates to be used
289-
to validate the certificates in incoming requests. The files in that
290-
directory must contain only one certificate each and the directory
291-
must be hashed using the OpenSSL 'c_rehash' utility.
293+
Path to a directory containing one or more hashed CA certs.
294+
See ca_file above.
295+
For this option, each certificate must be placed in its own
296+
PEM file in the directory specified and hashed with the
297+
following command:
298+
`openssl rehash <ca_path>`
292299

293-
Default: none
300+
Default: none
301+
See Also: [Certificate and CRL Notes](#certificate-and-crl-notes) below
294302

295303
NOTE: Both ca_file and ca_path can be specified but at least one
296304
MUST be.
297305

298306
##### crl_file
299-
Path to a single file containing a CA certificate revocation list
300-
to be used to validate the certificates in incoming requests.
307+
Path to a file containing one or more CRLs in PEM format.
308+
If you with to check if the certificate in the X5U Identity header
309+
parameter has been revoked, you'll need the certificate revocation
310+
list generated by the issuer. NOTE: CRLs are sometimes distributed
311+
in DER format instead of PEM format. You can covert a DER file to
312+
PEM with the folowing command:
313+
`openssl crl -inform DER -in crl.der -outform PEM -out crl.pem`
301314

302-
Default: none
315+
Default: none
316+
See Also: [Certificate and CRL Notes](#certificate-and-crl-notes) below
303317

304318
##### crl_path
305-
Path to a directory containing one or more CA certificate revocation
306-
lists to be used to validate the certificates in incoming requests.
307-
The files in that directory must contain only one certificate each and
308-
the directory must be hashed using the OpenSSL 'c_rehash' utility.
319+
Path to a directory containing one or more hashed CRLs.
320+
See crl_file above.
321+
For this option, each CRL must be placed in its own
322+
PEM file in the directory specified and hashed with the
323+
following command:
324+
`openssl rehash <crl_path>`
309325

310-
Default: none
326+
Default: none
327+
See Also: [Certificate and CRL Notes](#certificate-and-crl-notes) below
311328

312329
NOTE: Neither crl_file nor crl_path are required.
313330

331+
##### untrusted_cert_file
332+
Path to a file containing one or more untrusted certs in PEM format.
333+
Unfortunately, sometimes the CRLs are signed by a different CA
334+
than the certificate being verified. In this case, you'll need to
335+
provide the certificate belonging to the issuer of the CRL. That
336+
certificate is considered "untrusted" by OpenSSL and can't be placed
337+
in the ca_file or ca_path. It has to be specified here.
338+
339+
Default: none
340+
See Also: [Certificate and CRL Notes](#certificate-and-crl-notes) below.
341+
Added in Asterisk releases 18.25.0, 20.10.0, 21.5.0, certified-20.7-cert2
342+
343+
##### untrusted_cert_path
344+
Path to a directory containing one or more hashed untrusted certs used
345+
to verify CRLs.
346+
See untrusted_cert_file above.
347+
For this option, each certificates must be placed in its own
348+
PEM file in the directory specified and hashed with the
349+
following command:
350+
`openssl rehash <ca_path>`
351+
352+
Default: none
353+
See Also: [Certificate and CRL Notes](#certificate-and-crl-notes) below.
354+
Added in Asterisk releases 18.25.0, 20.10.0, 21.5.0, certified-20.7-cert2
355+
356+
NOTE: Neither untrusted_cert_file nor untrusted_cert_path are required
357+
unless you're verifying CRLs that aren't signed by the same CA as the
358+
X5U certificate.
359+
314360
##### cert_cache_dir
315361
Incoming Identity headers will have a URL pointing to the certificate
316362
used to sign the header. To prevent us from having to retrieve the
@@ -575,6 +621,140 @@ Compared to verification, attestation is simple.
575621
1. If there's no "tn" object matching the caller-id, skip attestation and continue the call. With the 18.23.0, 20.8.0 and 21.3.0 releases of Asterisk, the caller-id is canonicalized (everything except 0-9, # and * are removed) before a "tn" object is searched for. Previously, the caller-id had to match the "tn" id exactly so a caller-id of "+1234567890" would NOT match a "tn" id of "1234567890".
576622
1. Finally create and sign the Identity header using the `private_key_file`, `public_cert_url`, `attest_level` and `send_mky` parameters from [tn](#tn-object), [profile](#profile-object) or [attestation](#attestation-object). If this fails, the call will be terminated.
577623

624+
## Certificate and CRL Notes
625+
626+
Verifying the certificate retrieved by following the link in the received
627+
X5U Identity header parameter can be a tricky business. At a mimimum, you'll
628+
need the certificate of the X5U certificate's issuer. If the X5U certificate
629+
was signed by an intermediate certificate authority, you'll need that certificate
630+
plus any others up the chain to the issuer's root certificate authority.
631+
If you plan on verifying whether the X5U certificate has been revoked or not,
632+
you'll need the issuer's certificate revokation list and if the CRL was not
633+
signed by the same CA chain as the X5U certificate, you'll need the chain
634+
for the CRL as well.
635+
636+
If the X5U certificate was produced by an entity that knows how to
637+
properly set up and operate a PKI infrastructure, there are some easy
638+
steps you can take to find those certificates yourself. If not, you
639+
are unfortunately at their mercy to provide you with the proper files.
640+
anyway...
641+
642+
A properly constructed X5U certificate will have two X509 extensions
643+
that can help you get the issuer's certificate and, optionally, a CRL.
644+
If you have the URI in the X5U Identity header parameter, you can use
645+
`curl` to retrieve it manually...
646+
647+
```
648+
curl -o somecompany-x5u.pem https://somecompany.com/somecert.pem
649+
```
650+
651+
You can now dump the contents of the certificate with `openssl`...
652+
653+
```
654+
openssl x509 -in somecompany-x5u.pem -noout -text
655+
Certificate:
656+
<snipped>
657+
Issuer: CN=STO CA1 - SHAKEN Intermediate, O=Some Telecom Operator, OU=Certificate Authority, C=US
658+
<snipped>
659+
X509v3 extensions:
660+
Authority Information Access:
661+
CA Issuers - URI:https://somecomnany.com/ca/certs/intermediate-ca.cer
662+
X509v3 CRL Distribution Points:
663+
Full Name:
664+
URI:https://somecompany.com/crl CRL Issuer:
665+
DirName:CN = STO PA1, O = Some Telecom Operator, OU = Policy Authority, C = US
666+
```
667+
You'll notice a few things...
668+
* The issuer is an intermediate certificate authority.
669+
* The `Authority Information Access` extension has a URI to the intermediate CA's certificate.
670+
* There's a `CRL Distribution Points` extension with a URI to the CRL. This may or may not be present.
671+
* The CRL issuer isn't the same as this certificate's issuer. This is known as an "Indirect CRL". It's rare but it can happen.
672+
673+
So, now it's a matter of following those URIs, dumping the objects,
674+
and repeating until you reach the top.
675+
676+
```
677+
curl -o intermediate1-ca.pem https://somecomnany.com/ca/certs/intermediate1-ca.cer
678+
openssl x509 -in intermediate1-ca.pem -noout -text
679+
```
680+
Look for intermediate-ca.cer's `Authority Information Access` extension,
681+
download it, dump it, and repeat until you find the root CA certificate.
682+
You'll know it because its Issuer and Subject will be the same and there
683+
won't be a `Authority Information Access` extension. All of these certificates
684+
will need to be supplied in either [verification - ca_file](#ca_file) or
685+
[verification - ca_path](#ca_path).
686+
687+
If there was a CRL specified and you wish to check whether the X5U
688+
certificate was revoked or not, download and dump the CRL.
689+
690+
```
691+
curl -o somecompany.crl https://somecompany.com/crl
692+
openssl crl -in somecompany.crl -noout -text
693+
```
694+
695+
The CRL should also have an `Authority Information Access` extension that has
696+
the URI to the CRL issuer's certificate. If it's not the same as any of
697+
the certificates already retrieved by the above process, perform the same
698+
download and dump process as above until you get to the root CA certificate.
699+
Any of these certificates that weren't already retrieved above will need to be
700+
supplied in either [verification - untrusted_cert_file](#untrusted_cert_file) or
701+
[verification - untrusted_cert_path](#untrusted_cert_path).
702+
703+
The CRL itself will need to be supplied in either [verification - crl_file](#crl_file) or [verification - crl_path](#crl_path). Be aware though, some CRLs are
704+
distributed in DER format instead of PEM format. You can check which format
705+
was retrieved by running `file <crl_file>`. If the result is `ASCII text`, it's
706+
already PEM format. If the result is `data`, it's DER format. Since asterisk can only
707+
accept PEM format files, you'll need to convert the DER CRL into PEM format
708+
with the following command:
709+
710+
```
711+
openssl crl -inform DER -in somecompany.crl -outform PEM -out somecompany-crl.pem
712+
```
713+
714+
You can test that you have all the files needed for a successful verification
715+
by performing the following...
716+
717+
Concatenate all the CA certificates downloaded into a single file.
718+
719+
```
720+
cat intermediate1-ca.pem intermediate2-ca.pem root-ca.pem > somecompany-fullchain.pem
721+
```
722+
723+
Concatenate all the untrusted certificates downloaded into a single file.
724+
Don't include any CA certificates already downloaded previously.
725+
726+
```
727+
cat untrusted1-ca.pem untrusted2-ca.pem untrusted-ca.pem > somecompany-untrusted.pem
728+
```
729+
730+
Run the `openssl verify` command.
731+
732+
```
733+
openssl verify -CAfile somecompany-fullchain.pem -CRLfile somecompany-crl.pem \
734+
-untrusted somecompany-untrusted.pem -crl_check -extended_crl somecert-x5u.pem
735+
somecert-x5u.pem: OK
736+
```
737+
738+
If you're not checking against a CRL, you can leave those bits out...
739+
740+
```
741+
openssl verify -CAfile somecompany-fullchain.pem somecert-x5u.pem
742+
somecert-x5u.pem: OK
743+
```
744+
745+
You can use the same somecompany-fullchain.pem, somecompany-crl.pem,
746+
and somecompany-untrusted.pem file as the values for the
747+
[verification - ca_file](#ca_file), [verification - crl_file](#crl_file)
748+
and [verification - untrusted_cert_file](#untrusted_cert_file)
749+
stir_shaken.conf values.
750+
751+
Starting in Asterisk versions, 18.25.0, 20.10.0, 21.5.0 and certified-20.7-cert2,
752+
a new CLI command `stir_shaken verify certificate_file` is available. If you've properly
753+
configured the ca, crl and untrusted_cert parameters in stir_shaken.conf, you can
754+
check if Asterisk can verify a certificate with the following command:
755+
`CLI> stir_shaken verify certificate_file <path_to_cert_file>`.
756+
You'll get the same results you'd get with the `openssl verify` command.
757+
578758
## References
579759

580760
The best places to become familiar with STIR/SHAKEN itself are:

0 commit comments

Comments
 (0)