Skip to content

Commit

Permalink
cryptographic-message-syntax: introduce http crate feature
Browse files Browse the repository at this point in the history
This slims down the dependency tree significantly if the feature
is disabled.

Closes #21.
  • Loading branch information
latonis authored and indygreg committed Nov 2, 2024
1 parent beb6c03 commit 5c563fa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- name: Build Workspace
run: |
rustc --version
cargo build --workspace --no-default-features
cargo build --workspace
cargo test --workspace --no-run
Expand Down
4 changes: 4 additions & 0 deletions cryptographic-message-syntax/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
Released on ReleaseDate.

* MSRV 1.65 -> 1.75.
* The crate now has an `http` feature to control availability of features making
HTTP requests (notably time-stamp protocol support). Disabling the feature
removes the dependency on `reqwest`, which slims down the dependency tree
significantly. (#21)
* `bytes` 1.5 -> 1.8.
* `reqwest` 0.11 -> 0.12.
* `signature` 2.1 -> 2.2.
Expand Down
6 changes: 5 additions & 1 deletion cryptographic-message-syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ bytes = "1.8.0"
chrono = { version = "0.4.38", default-features = false }
hex = "0.4.3"
pem = "3.0.4"
reqwest = { version = "0.12.9", default-features = false, features = ["blocking", "rustls-tls"] }
reqwest = { version = "0.12.9", default-features = false, features = ["blocking", "rustls-tls"], optional = true }
ring = "0.17.8"
signature = { version = "2.2.0", features = ["std"] }

[dependencies.x509-certificate]
path = "../x509-certificate"
version = "0.23.0"
features = ["test"]

[features]
default = ["http"]
http = ["dep:reqwest"]
11 changes: 9 additions & 2 deletions cryptographic-message-syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,22 @@ structures referenced by RFC5652 and taught them to serialize using `bcder`.
*/

pub mod asn1;

#[cfg(feature = "http")]
mod signing;
#[cfg(feature = "http")]
mod time_stamp_protocol;

#[cfg(feature = "http")]
pub use {
bcder::Oid,
bytes::Bytes,
signing::{SignedDataBuilder, SignerBuilder},
time_stamp_protocol::{
time_stamp_message_http, time_stamp_request_http, TimeStampError, TimeStampResponse,
},
};

pub use {bcder::Oid, bytes::Bytes};

use {
crate::asn1::{
rfc3161::OID_TIME_STAMP_TOKEN,
Expand Down Expand Up @@ -171,6 +175,7 @@ pub enum CmsError {
/// Error occurred parsing a distinguished name field in a certificate.
DistinguishedNameParseError,

#[cfg(feature = "http")]
/// Error occurred in Time-Stamp Protocol.
TimeStampProtocol(TimeStampError),

Expand Down Expand Up @@ -228,6 +233,7 @@ impl Display for CmsError {
Self::DistinguishedNameParseError => {
f.write_str("could not parse distinguished name data")
}
#[cfg(feature = "http")]
Self::TimeStampProtocol(e) => {
f.write_fmt(format_args!("Time-Stamp Protocol error: {}", e))
}
Expand Down Expand Up @@ -256,6 +262,7 @@ impl From<PemError> for CmsError {
}
}

#[cfg(feature = "http")]
impl From<TimeStampError> for CmsError {
fn from(e: TimeStampError) -> Self {
Self::TimeStampProtocol(e)
Expand Down

0 comments on commit 5c563fa

Please sign in to comment.