@@ -39,7 +39,7 @@ const ZLINT_CONFIG: &str = &"
39
39
Rounds = 100
40
40
" ;
41
41
42
- fn check_certificate ( cert : & Certificate ) {
42
+ fn check_certificate ( cert : & Certificate , ignored : & [ & str ] ) {
43
43
let tmp_dir = tempdir ( ) . expect ( "create tempdir" ) ;
44
44
let config_path = tmp_dir. path ( ) . join ( "config.toml" ) ;
45
45
let cert_path = tmp_dir. path ( ) . join ( "cert.pem" ) ;
@@ -78,7 +78,6 @@ fn check_certificate(cert: &Certificate) {
78
78
let output: zlint:: LintResult =
79
79
serde_json:: from_slice ( & output_buf) . expect ( "parse zlint output" ) ;
80
80
81
- let ignored = & [ ] ;
82
81
assert ! ( output. check_lints( ignored) ) ;
83
82
}
84
83
@@ -103,20 +102,21 @@ fn root_ca_certificate() {
103
102
104
103
let mut builder = CertificateBuilder :: new (
105
104
profile,
106
- CertificateVersion :: V3 { uids } ,
105
+ CertificateVersion :: V3 ( uids) ,
107
106
serial_number,
108
- constants:: RsaWithSha256 ,
109
107
validity,
110
108
subject,
111
109
pub_key,
110
+ & RsaCertSigner ,
112
111
)
113
112
. expect ( "Create certificate" ) ;
114
113
115
- let certificate = builder. build ( RsaCertSigner ) . unwrap ( ) ;
114
+ let certificate = builder. build ( ) . unwrap ( ) ;
116
115
117
116
println ! ( "{}" , openssl:: text_output( & certificate) ) ;
118
117
119
- check_certificate ( & certificate) ;
118
+ let ignored = & [ ] ;
119
+ check_certificate ( & certificate, ignored) ;
120
120
}
121
121
122
122
#[ test]
@@ -147,20 +147,29 @@ fn sub_ca_certificate() {
147
147
148
148
let mut builder = CertificateBuilder :: new (
149
149
profile,
150
- CertificateVersion :: V3 { uids } ,
150
+ CertificateVersion :: V3 ( uids) ,
151
151
serial_number,
152
- constants:: RsaWithSha256 ,
152
+ // constants::RsaWithSha256,
153
153
validity,
154
154
subject,
155
155
pub_key,
156
+ & RsaCertSigner ,
156
157
)
157
158
. expect ( "Create certificate" ) ;
158
159
159
- let certificate = builder. build ( RsaCertSigner ) . unwrap ( ) ;
160
+ let certificate = builder. build ( ) . unwrap ( ) ;
160
161
161
162
println ! ( "{}" , openssl:: text_output( & certificate) ) ;
162
163
163
- check_certificate ( & certificate) ;
164
+ // TODO(baloo): not too sure we should tackle those in this API.
165
+ let ignored = & [
166
+ "w_sub_ca_aia_missing" ,
167
+ "e_sub_ca_crl_distribution_points_missing" ,
168
+ "e_sub_ca_certificate_policies_missing" ,
169
+ "w_sub_ca_aia_does_not_contain_issuing_ca_url" ,
170
+ ] ;
171
+
172
+ check_certificate ( & certificate, ignored) ;
164
173
}
165
174
166
175
const RSA_2048_PRIV_DER_EXAMPLE : & [ u8 ] = include_bytes ! ( "examples/rsa2048-priv.der" ) ;
@@ -170,6 +179,14 @@ struct RsaCertSigner;
170
179
impl Signer for RsaCertSigner {
171
180
type Alg = constants:: RsaWithSha256 ;
172
181
182
+ fn signature_algorithm ( & self ) -> Self :: Alg {
183
+ constants:: RsaWithSha256
184
+ }
185
+
186
+ fn public_key ( & self ) -> SubjectPublicKeyInfo {
187
+ SubjectPublicKeyInfo :: try_from ( RSA_2048_DER_EXAMPLE ) . expect ( "get rsa pub key" )
188
+ }
189
+
173
190
fn sign ( & self , input : & TbsCertificate < ' _ > ) -> Vec < u8 > {
174
191
use rsa:: pkcs1v15:: SigningKey ;
175
192
use rsa:: signature:: { RandomizedSigner , Signature } ;
0 commit comments