Skip to content

Commit 99af3b0

Browse files
committed
feat: ✨ make IPAddress optional for client and server certs
1 parent 1d37eef commit 99af3b0

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

test-certs/src/configuration/certificates.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub struct ServerConfiguration {
7070
#[serde(deny_unknown_fields)]
7171
pub struct SubjectAlternativeNames {
7272
/// Ip addresses of the client.
73+
#[serde(default)]
7374
#[serde_as(as = "OneOrMany<_, PreferOne>")]
7475
pub ip: Vec<IpAddr>,
7576

@@ -306,6 +307,27 @@ mod tests {
306307

307308
#[test]
308309
fn should_deserialize_client() {
310+
let expected = ClientConfiguration {
311+
export_key: false,
312+
subject_alternative_names: SubjectAlternativeNames {
313+
ip: vec![],
314+
dns_name: vec!["my-client.org".to_string()],
315+
},
316+
include_certificate_chain: false,
317+
};
318+
let json = json!({
319+
"export_key": false,
320+
"dns_name": "my-client.org",
321+
"include_certificate_chain": false
322+
});
323+
324+
let deserialized: ClientConfiguration = serde_json::from_value(json).unwrap();
325+
326+
assert_eq!(deserialized, expected)
327+
}
328+
329+
#[test]
330+
fn should_deserialize_client_with_ip() {
309331
let expected = ClientConfiguration {
310332
export_key: false,
311333
subject_alternative_names: SubjectAlternativeNames {

test-certs/tests/examples/intermediate_ca.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Creates a root ca
22
my-root-ca:
3-
# the my-root-ca key file is by default not exported
3+
# The my-root-ca key file is by default not exported
44
type: ca
55
certificates:
6-
# my-intermediate-ca is issued by my-root-ca
6+
# The my-intermediate-ca is issued by my-root-ca
77
my-intermediate-ca:
88
type: ca
9-
# We want to export the my-intermediate-ca key to be exported
9+
# We want the my-intermediate-ca key to be exported
1010
export_key: true
1111
certificates:
1212
# Create a client auth certificate issued by my-intermediate-ca

0 commit comments

Comments
 (0)