Skip to content

Commit 54e18d1

Browse files
committed
x509-cert: builder: don't require mutability of the signer
Signer (unlike SignerMut) is not expected to be mutable. Don't require mutability of the Signer argument. Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 49dbc6d commit 54e18d1

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

x509-cert/src/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ impl Profile {
227227
/// validity,
228228
/// subject,
229229
/// pub_key,
230-
/// &mut signer,
230+
/// &signer,
231231
/// )
232232
/// .expect("Create certificate");
233233
/// ```
234234
pub struct CertificateBuilder<'s, S> {
235235
tbs: TbsCertificate,
236-
signer: &'s mut S,
236+
signer: &'s S,
237237
}
238238

239239
impl<'s, S> CertificateBuilder<'s, S>
@@ -249,7 +249,7 @@ where
249249
mut validity: Validity,
250250
subject: Name,
251251
subject_public_key_info: SubjectPublicKeyInfoOwned,
252-
signer: &'s mut S,
252+
signer: &'s S,
253253
) -> Result<Self>
254254
where
255255
S: Signer<Signature>,
@@ -315,7 +315,7 @@ where
315315
}
316316

317317
/// Run the certificate through the signer and build the end certificate.
318-
pub fn build<Signature>(&mut self) -> Result<Certificate>
318+
pub fn build<Signature>(self) -> Result<Certificate>
319319
where
320320
S: Signer<Signature>,
321321
Signature: SignatureEncoding,
@@ -325,7 +325,7 @@ where
325325

326326
let cert = Certificate {
327327
tbs_certificate: self.tbs.clone(),
328-
signature_algorithm: self.tbs.signature.clone(),
328+
signature_algorithm: self.tbs.signature,
329329
signature,
330330
};
331331

x509-cert/tests/builder.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ fn root_ca_certificate() {
3131
let pub_key =
3232
SubjectPublicKeyInfoOwned::try_from(RSA_2048_DER_EXAMPLE).expect("get rsa pub key");
3333

34-
let mut signer = rsa_signer();
35-
let mut builder = CertificateBuilder::new(
34+
let signer = rsa_signer();
35+
let builder = CertificateBuilder::new(
3636
profile,
3737
Version::V3,
3838
serial_number,
3939
validity,
4040
subject,
4141
pub_key,
42-
&mut signer,
42+
&signer,
4343
)
4444
.expect("Create certificate");
4545

@@ -75,15 +75,15 @@ fn sub_ca_certificate() {
7575
let pub_key =
7676
SubjectPublicKeyInfoOwned::try_from(RSA_2048_DER_EXAMPLE).expect("get rsa pub key");
7777

78-
let mut signer = ecdsa_signer();
79-
let mut builder = CertificateBuilder::new::<ecdsa::Signature<NistP256>>(
78+
let signer = ecdsa_signer();
79+
let builder = CertificateBuilder::new::<ecdsa::Signature<NistP256>>(
8080
profile,
8181
Version::V3,
8282
serial_number,
8383
validity,
8484
subject,
8585
pub_key,
86-
&mut signer,
86+
&signer,
8787
)
8888
.expect("Create certificate");
8989

@@ -126,15 +126,15 @@ fn leaf_certificate() {
126126
let pub_key =
127127
SubjectPublicKeyInfoOwned::try_from(RSA_2048_DER_EXAMPLE).expect("get rsa pub key");
128128

129-
let mut signer = ecdsa_signer();
130-
let mut builder = CertificateBuilder::new::<ecdsa::Signature<NistP256>>(
129+
let signer = ecdsa_signer();
130+
let builder = CertificateBuilder::new::<ecdsa::Signature<NistP256>>(
131131
profile,
132132
Version::V3,
133133
serial_number,
134134
validity,
135135
subject,
136136
pub_key,
137-
&mut signer,
137+
&signer,
138138
)
139139
.expect("Create certificate");
140140

0 commit comments

Comments
 (0)