-
Notifications
You must be signed in to change notification settings - Fork 80
Dev/update version and notes #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 7 commits
72a238b
476e129
132c62e
de645db
fe00500
7d94bc4
1a2e8b4
be8dfc7
8b1afd6
694bcf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| <!-- cargo-sync-readme start --> | ||
|
|
||
| [](./LICENSE-MIT) | ||
| [](./LICENSE-APACHE) | ||
| [](https://docs.rs/x509-parser) | ||
|
|
@@ -8,6 +6,8 @@ | |
| [](https://github.com/rusticata/x509-parser/actions) | ||
| [](#rust-version-requirements) | ||
|
|
||
| <!-- cargo-rdme start --> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately it seems like this commit is breaking many markdown links in the rendered preview (https://github.com/rusticata/x509-parser/blob/fe005007af027b0cbf24f8a8bd8fadac204df527/README.md) I think the link targets aren't quite right.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Would also be nice to get #230 merged)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an annoying limitation of The last solution is to strip the intradoc links when generating the README.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About #230 , I cherry-picked the commit in this branch with a few changes to resolve the conflicts and change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Bummer :-( Would you be open to a more direct/dumber solution? We use a small script in I don't think we've had any significant trouble/friction with this approach but it's not quite as polished as a dedicated tool like
I wonder if it's possible to silence/allow just that one warning about redundant paths. That seems preferable to allowing all warnings, or stripping links if you want to stick with |
||
|
|
||
| # X.509 Parser | ||
|
|
||
| A X.509 v3 ([RFC5280]) parser, implemented with the [nom](https://github.com/Geal/nom) | ||
|
|
@@ -22,25 +22,36 @@ and is part of the [Rusticata](https://github.com/rusticata) project. | |
|
|
||
| Certificates are usually encoded in two main formats: PEM (usually the most common format) or | ||
| DER. A PEM-encoded certificate is a container, storing a DER object. See the | ||
| [`pem`](https://docs.rs/x509-parser/latest/x509_parser/pem/index.html) module for more documentation. | ||
| [`pem`] module for more documentation. | ||
|
|
||
| To decode a DER-encoded certificate, the main parsing method is | ||
| `X509Certificate::from_der` ( | ||
| part of the [`FromDer`](https://docs.rs/x509-parser/latest/x509_parser/prelude/trait.FromDer.html) trait | ||
| ), which builds a | ||
| [`X509Certificate`](https://docs.rs/x509-parser/latest/x509_parser/certificate/struct.X509Certificate.html) object. | ||
| `X509Certificate::parse_der` (from the [`DerParser`](asn1_rs::DerParser) trait) | ||
| which builds a [`X509Certificate`] object. | ||
|
|
||
| The [`parse_der`](asn1_rs::DerParser) trait takes an [`Input`](asn1_rs::Input) | ||
| object, which can be built from the input bytes. This helps tracking offsets (in case of | ||
| error). | ||
| For convenience, | ||
| the [`X509Certificate::from_der`] method (part of the [`FromDer`] trait) | ||
| does the same directly on the input bytes, but it can loose the precise error location. | ||
|
|
||
| An alternative method is to use [`X509CertificateParser`](https://docs.rs/x509-parser/latest/x509_parser/certificate/struct.X509CertificateParser.html), | ||
| which allows specifying parsing options (for example, not automatically parsing option contents). | ||
|
|
||
| Similar methods are provided for other X.509 objects: | ||
| - [`X509Certificate`] for X.509 Certificates | ||
| - [`CertificateRevocationList`] for X.509 v2 Certificate Revocation List (CRL) | ||
| - [`X509CertificationRequest`](https://docs.rs/x509-parser/latest/x509_parser/certification_request/struct.X509CertificationRequest.html) for Certification Signing Request (CSR) | ||
|
|
||
| The returned objects for parsers follow the definitions of the RFC. This means that accessing | ||
| fields is done by accessing struct members recursively. Some helper functions are provided, for | ||
| example [`X509Certificate::issuer()`](https://docs.rs/x509-parser/latest/x509_parser/certificate/struct.X509Certificate.html#method.issuer) returns the | ||
| example `X509Certificate::issuer()` returns the | ||
| same as accessing `<object>.tbs_certificate.issuer`. | ||
|
|
||
| For PEM-encoded certificates, use the [`pem`](https://docs.rs/x509-parser/latest/x509_parser/pem/index.html) module. | ||
| For PEM-encoded certificates, use the [`pem`] module. | ||
|
|
||
| This crate also provides visitor traits: [`X509CertificateVisitor`](crate::visitor::X509CertificateVisitor). | ||
| This crate also provides visitor traits: `X509CertificateVisitor`, `CertificateRevocationListVisitor`. | ||
| See the [`visitor`] module. | ||
|
|
||
| # Examples | ||
|
|
||
|
|
@@ -51,7 +62,8 @@ use x509_parser::prelude::*; | |
|
|
||
| static IGCA_DER: &[u8] = include_bytes!("../assets/IGC_A.der"); | ||
|
|
||
| let res = X509Certificate::from_der(IGCA_DER); | ||
| let input = Input::from(IGCA_DER); | ||
| let res = X509Certificate::parse_der(input); | ||
| match res { | ||
| Ok((rem, cert)) => { | ||
| assert!(rem.is_empty()); | ||
|
|
@@ -65,9 +77,8 @@ match res { | |
| To parse a CRL and print information about revoked certificates: | ||
|
|
||
| ```rust | ||
| # | ||
| # | ||
| let res = CertificateRevocationList::from_der(DER); | ||
| let input = Input::from(DER); | ||
| let res = CertificateRevocationList::parse_der(input); | ||
| match res { | ||
| Ok((_rem, crl)) => { | ||
| for revoked in crl.iter_revoked_certificates() { | ||
|
|
@@ -85,7 +96,7 @@ See also `examples/print-cert.rs`. | |
|
|
||
| - The `verify` and `verify-aws` features adds support for (cryptographic) signature verification, based on `ring` or `aws-lc` respectively. | ||
| It adds the | ||
| [`X509Certificate::verify_signature()`](https://docs.rs/x509-parser/latest/x509_parser/certificate/struct.X509Certificate.html#method.verify_signature) | ||
| [`X509Certificate::verify_signature()`] method | ||
| to `X509Certificate`. | ||
|
|
||
| ```rust | ||
|
|
@@ -99,6 +110,13 @@ pub fn check_signature(cert: &X509Certificate<'_>, issuer: &X509Certificate<'_>) | |
| } | ||
| ``` | ||
|
|
||
| - The `verify-aws` feature offers the same support for signature verification, but based on | ||
| `aws-lc-rs` instead of `ring`. | ||
|
|
||
| - _Note_: if both `verify` and `verify-aws` features are enabled (which happens when using | ||
| `--all-features`), the verification will use `aws-lc-rs`. It also has the side-effect of | ||
| having a dependency on `ring`, even if it is not used. | ||
|
|
||
| - The `validate` features add methods to run more validation functions on the certificate structure | ||
| and values using the [`Validate`](https://docs.rs/x509-parser/latest/x509_parser/validate/trait.Validate.html) trait. | ||
| It does not validate any cryptographic parameter (see `verify` above). | ||
|
|
@@ -109,7 +127,18 @@ pub fn check_signature(cert: &X509Certificate<'_>, issuer: &X509Certificate<'_>) | |
| dependencies and for proc-macro attributes support. | ||
|
|
||
| [RFC5280]: https://tools.ietf.org/html/rfc5280 | ||
| <!-- cargo-sync-readme end --> | ||
|
|
||
| <!-- cargo-rdme end --> | ||
|
|
||
| ## MSRV policy | ||
|
|
||
| This projects tries to maintain compatibility with older version of the rust compiler for the following | ||
chifflier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| durations: | ||
| - `master` branch: _12 months_ minimum | ||
| - older releases: about 24 months | ||
|
|
||
| However, due to dependencies and the fact that some crate writers tend to require very recent | ||
| versions of the compiler, this can prove to be difficult. These numbers are given as _best-effort_. | ||
cpu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Changes | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.