Skip to content

Commit c8455df

Browse files
committed
x509-cert: use type aliases
1 parent c1e4f94 commit c8455df

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

x509-cert/src/certificate.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ impl<P: Profile> TbsCertificate<P> {
169169
}
170170
}
171171

172+
/// X.509 certificates are defined in [RFC 5280 Section 4.1].
173+
///
174+
/// [RFC 5280 Section 4.1]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1
175+
pub type Certificate = CertificateInner<Rfc5280>;
176+
172177
/// X.509 certificates are defined in [RFC 5280 Section 4.1].
173178
///
174179
/// ```text
@@ -183,14 +188,14 @@ impl<P: Profile> TbsCertificate<P> {
183188
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
184189
#[derive(Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)]
185190
#[allow(missing_docs)]
186-
pub struct Certificate<P: Profile = Rfc5280> {
191+
pub struct CertificateInner<P: Profile = Rfc5280> {
187192
pub tbs_certificate: TbsCertificate<P>,
188193
pub signature_algorithm: AlgorithmIdentifierOwned,
189194
pub signature: BitString,
190195
}
191196

192197
#[cfg(feature = "pem")]
193-
impl<P: Profile> PemLabel for Certificate<P> {
198+
impl<P: Profile> PemLabel for CertificateInner<P> {
194199
const PEM_LABEL: &'static str = "CERTIFICATE";
195200
}
196201

x509-cert/tests/certificate.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use x509_cert::Certificate;
1212
use x509_cert::*;
1313

1414
#[cfg(feature = "pem")]
15-
use der::{pem::LineEnding, DecodePem, EncodePem};
15+
use der::DecodePem;
1616

1717
// TODO - parse and compare extension values
1818
const EXTENSIONS: &[(&str, bool)] = &[
@@ -403,7 +403,7 @@ fn decode_cert() {
403403
fn decode_cert_negative_serial_number() {
404404
let der_encoded_cert = include_bytes!("examples/28903a635b5280fae6774c0b6da7d6baa64af2e8.der");
405405

406-
let cert = Certificate::<Rfc5280>::from_der(der_encoded_cert).unwrap();
406+
let cert = Certificate::from_der(der_encoded_cert).unwrap();
407407
assert_eq!(
408408
cert.tbs_certificate.serial_number.as_bytes(),
409409
// INTEGER (125 bit) -2.370157924795571e+37
@@ -417,11 +417,14 @@ fn decode_cert_negative_serial_number() {
417417
#[cfg(all(feature = "pem", feature = "hazmat"))]
418418
#[test]
419419
fn decode_cert_overlength_serial_number() {
420+
use der::{pem::LineEnding, DecodePem, EncodePem};
421+
use x509_cert::certificate::CertificateInner;
422+
420423
let pem_encoded_cert = include_bytes!("examples/qualcomm.pem");
421424

422-
assert!(Certificate::<Rfc5280>::from_pem(pem_encoded_cert).is_err());
425+
assert!(Certificate::from_pem(pem_encoded_cert).is_err());
423426

424-
let cert = Certificate::<x509_cert::certificate::Raw>::from_pem(pem_encoded_cert).unwrap();
427+
let cert = CertificateInner::<x509_cert::certificate::Raw>::from_pem(pem_encoded_cert).unwrap();
425428
assert_eq!(
426429
cert.tbs_certificate.serial_number.as_bytes(),
427430
&[

0 commit comments

Comments
 (0)