@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
66
77/// This is the root structure that contains all certificate chains.
88#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
9- pub struct Certificates {
9+ pub struct CertificateRoot {
1010 /// All certificates
1111 #[ serde( flatten) ]
1212 pub certificates : HashMap < String , CertificateTypes > ,
@@ -15,7 +15,7 @@ pub struct Certificates {
1515/// The certificate authority to sign other certificates.
1616#[ derive( Debug , Default , Serialize , Deserialize , PartialEq , Eq ) ]
1717#[ serde( default , deny_unknown_fields) ]
18- pub struct CertificateAuthority {
18+ pub struct CertificateAuthorityConfiguration {
1919 /// Enables the export of the private key file.
2020 pub export_key : bool ,
2121
@@ -27,15 +27,15 @@ pub struct CertificateAuthority {
2727/// A certificate used for client authentication.
2828#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
2929#[ serde( default , deny_unknown_fields) ]
30- pub struct Client {
30+ pub struct ClientConfiguration {
3131 /// Enables the export of the private key file.
3232 pub export_key : bool ,
3333}
3434
3535/// A certificate used for server authentication.
3636#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
3737#[ serde( default , deny_unknown_fields) ]
38- pub struct Server {
38+ pub struct ServerConfiguration {
3939 /// Enables the export of the private key file.
4040 pub export_key : bool ,
4141}
@@ -46,13 +46,13 @@ pub struct Server {
4646pub enum CertificateTypes {
4747 /// A certificate that acts as a Certificate Authority.
4848 #[ serde( alias = "ca" ) ]
49- CertificateAuthority ( CertificateAuthority ) ,
49+ CertificateAuthority ( CertificateAuthorityConfiguration ) ,
5050
5151 /// A certificate for client authentication.
52- Client ( Client ) ,
52+ Client ( ClientConfiguration ) ,
5353
5454 /// A certificate for server authentication.
55- Server ( Server ) ,
55+ Server ( ServerConfiguration ) ,
5656}
5757
5858impl CertificateTypes {
@@ -83,13 +83,13 @@ impl CertificateTypes {
8383/// The [`LazyLock`] is required as a HashMap::new is not usable in const expressions.
8484static NO_CERTIFICATES : LazyLock < HashMap < String , CertificateTypes > > = LazyLock :: new ( HashMap :: new) ;
8585
86- impl Default for Client {
86+ impl Default for ClientConfiguration {
8787 fn default ( ) -> Self {
8888 Self { export_key : true }
8989 }
9090}
9191
92- impl Default for Server {
92+ impl Default for ServerConfiguration {
9393 fn default ( ) -> Self {
9494 Self { export_key : true }
9595 }
@@ -101,46 +101,46 @@ pub mod fixtures {
101101 use super :: * ;
102102
103103 /// Creates a certificate authority and a server and client certificated that are issued by it.
104- pub fn certificate_ca_with_client ( ) -> Certificates {
105- let certs = Certificates {
104+ pub fn certificate_ca_with_client ( ) -> CertificateRoot {
105+ let certs = CertificateRoot {
106106 certificates : HashMap :: from ( [ ( "ca" . to_string ( ) , ca_with_client ( ) ) ] ) ,
107107 } ;
108108 certs
109109 }
110110
111111 /// Creates a certificate of type ca with a client cert.
112112 pub fn ca_with_client ( ) -> CertificateTypes {
113- CertificateTypes :: CertificateAuthority ( CertificateAuthority {
113+ CertificateTypes :: CertificateAuthority ( CertificateAuthorityConfiguration {
114114 certificates : HashMap :: from ( [ (
115115 "client" . to_string ( ) ,
116- CertificateTypes :: Client ( Client :: default ( ) ) ,
116+ CertificateTypes :: Client ( ClientConfiguration :: default ( ) ) ,
117117 ) ] ) ,
118118 ..Default :: default ( )
119119 } )
120120 }
121121
122122 /// Creates a client certificate.
123- pub fn certificate_client ( ) -> Certificates {
124- let certs = Certificates {
123+ pub fn certificate_client ( ) -> CertificateRoot {
124+ let certs = CertificateRoot {
125125 certificates : HashMap :: from ( [ (
126126 "client" . to_string ( ) ,
127- CertificateTypes :: Client ( Client :: default ( ) ) ,
127+ CertificateTypes :: Client ( ClientConfiguration :: default ( ) ) ,
128128 ) ] ) ,
129129 } ;
130130 certs
131131 }
132132
133133 /// Creates a certificate of type client.
134134 pub fn client ( ) -> CertificateTypes {
135- CertificateTypes :: Client ( Client :: default ( ) )
135+ CertificateTypes :: Client ( ClientConfiguration :: default ( ) )
136136 }
137137
138138 /// Creates a certificate authority without any other certificates.
139- pub fn certificate_ca ( ) -> Certificates {
140- let certs = Certificates {
139+ pub fn certificate_ca ( ) -> CertificateRoot {
140+ let certs = CertificateRoot {
141141 certificates : HashMap :: from ( [ (
142142 "ca" . to_string ( ) ,
143- CertificateTypes :: CertificateAuthority ( CertificateAuthority :: default ( ) ) ,
143+ CertificateTypes :: CertificateAuthority ( CertificateAuthorityConfiguration :: default ( ) ) ,
144144 ) ] ) ,
145145 } ;
146146 certs
@@ -153,7 +153,7 @@ mod tests {
153153 use fixtures:: certificate_ca_with_client;
154154 use serde_json:: json;
155155
156- fn get_ca ( cert : & CertificateTypes ) -> & CertificateAuthority {
156+ fn get_ca ( cert : & CertificateTypes ) -> & CertificateAuthorityConfiguration {
157157 assert ! ( matches!( cert, CertificateTypes :: CertificateAuthority ( _) ) ) ;
158158 let ca = match cert {
159159 CertificateTypes :: CertificateAuthority ( certificate_authority) => certificate_authority,
@@ -222,7 +222,7 @@ mod tests {
222222 let certs = certificate_ca_with_client ( ) ;
223223
224224 let serialized = serde_json:: to_string ( & certs) . unwrap ( ) ;
225- let deserialized: Certificates = serde_json:: from_str ( & serialized) . unwrap ( ) ;
225+ let deserialized: CertificateRoot = serde_json:: from_str ( & serialized) . unwrap ( ) ;
226226
227227 assert_eq ! ( deserialized, certs)
228228 }
@@ -233,10 +233,10 @@ mod tests {
233233
234234 #[ test]
235235 fn should_serialize_certificateauthority ( ) {
236- let certificates = Certificates {
236+ let certificates = CertificateRoot {
237237 certificates : HashMap :: from ( [ (
238238 "my-ca" . to_string ( ) ,
239- CertificateTypes :: CertificateAuthority ( CertificateAuthority {
239+ CertificateTypes :: CertificateAuthority ( CertificateAuthorityConfiguration {
240240 certificates : HashMap :: new ( ) ,
241241 export_key : false ,
242242 } ) ,
@@ -277,7 +277,7 @@ mod tests {
277277 let certs = certificate_ca_with_client ( ) ;
278278
279279 let serialized = serde_yaml:: to_string ( & certs) . unwrap ( ) ;
280- let deserialized: Certificates = serde_yaml:: from_str ( & serialized) . unwrap ( ) ;
280+ let deserialized: CertificateRoot = serde_yaml:: from_str ( & serialized) . unwrap ( ) ;
281281
282282 assert_eq ! ( deserialized, certs)
283283 }
0 commit comments