-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: renaming of TLS configuration parameters #1503
Changes from 2 commits
12a74cf
898b975
3d5da78
2226121
22ee3f9
bf10a91
55f41b2
d82231c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,20 +431,21 @@ | |
/// or the client's keys and certificates, depending on the node's mode. If not specified | ||
/// on router mode then the default WebPKI certificates are used instead. | ||
root_ca_certificate: null, | ||
/// Path to the TLS server private key | ||
server_private_key: null, | ||
/// Path to the TLS server public certificate | ||
server_certificate: null, | ||
/// Client authentication, if true enables mTLS (mutual authentication) | ||
client_auth: false, | ||
/// Path to the TLS client private key | ||
client_private_key: null, | ||
/// Path to the TLS client public certificate | ||
client_certificate: null, | ||
// Whether or not to use server name verification, if set to false zenoh will disregard the common names of the certificates when verifying servers. | ||
/// Path to the TLS listening side private key | ||
listen_private_key: null, | ||
/// Path to the TLS listening side public certificate | ||
listen_certificate: null, | ||
/// Enables mTLS (mutual authentication), client authentication | ||
enable_mtls: false, | ||
/// Path to the TLS connecting side private key | ||
connect_private_key: null, | ||
/// Path to the TLS client connecting side certificate | ||
connect_certificate: null, | ||
// Whether or not to verify the matching between hostname/dns and certificate when connecting, | ||
// if set to false zenoh will disregard the common names of the certificates when verifying servers. | ||
// This could be dangerous because your CA can have signed a server cert for foo.com, that's later being used to host a server at baz.com. If you wan't your | ||
// ca to verify that the server at baz.com is actually baz.com, let this be true (default). | ||
server_name_verification: null, | ||
verify_name_on_connect: null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comments above indicate the value for thic config can be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH, I do not know, let me set it as |
||
}, | ||
}, | ||
/// Shared memory configuration. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,24 +92,24 @@ pub mod config { | |
pub const TLS_ROOT_CA_CERTIFICATE_RAW: &str = "root_ca_certificate_raw"; | ||
pub const TLS_ROOT_CA_CERTIFICATE_BASE64: &str = "root_ca_certificate_base64"; | ||
|
||
pub const TLS_SERVER_PRIVATE_KEY_FILE: &str = "server_private_key_file"; | ||
pub const TLS_SERVER_PRIVATE_KEY_RAW: &str = "server_private_key_raw"; | ||
pub const TLS_SERVER_PRIVATE_KEY_BASE64: &str = "server_private_key_base64"; | ||
pub const TLS_LISTEN_PRIVATE_KEY_FILE: &str = "listen_private_key_file"; | ||
pub const TLS_LISTEN_PRIVATE_KEY_RAW: &str = "listen_private_key_raw"; | ||
pub const TLS_LISTEN_PRIVATE_KEY_BASE64: &str = "listen_private_key_base64"; | ||
|
||
pub const TLS_SERVER_CERTIFICATE_FILE: &str = "server_certificate_file"; | ||
pub const TLS_SERVER_CERTIFICATE_RAW: &str = "server_certificate_raw"; | ||
pub const TLS_SERVER_CERTIFICATE_BASE64: &str = "server_certificate_base64"; | ||
pub const TLS_LISTEN_CERTIFICATE_FILE: &str = "listen_certificate_file"; | ||
pub const TLS_LISTEN_CERTIFICATE_RAW: &str = "listen_certificate_raw"; | ||
pub const TLS_LISTEN_CERTIFICATE_BASE64: &str = "listen_certificate_base64"; | ||
|
||
pub const TLS_CLIENT_PRIVATE_KEY_FILE: &str = "client_private_key_file"; | ||
pub const TLS_CLIENT_PRIVATE_KEY_RAW: &str = "client_private_key_raw"; | ||
pub const TLS_CLIENT_PRIVATE_KEY_BASE64: &str = "client_private_key_base64"; | ||
pub const TLS_CONNECT_PRIVATE_KEY_FILE: &str = "connect_private_key_file"; | ||
pub const TLS_CONNECT_PRIVATE_KEY_RAW: &str = "connect_private_key_raw"; | ||
pub const TLS_CONNECT_PRIVATE_KEY_BASE64: &str = "connect_private_key_base64"; | ||
|
||
pub const TLS_CLIENT_CERTIFICATE_FILE: &str = "client_certificate_file"; | ||
pub const TLS_CLIENT_CERTIFICATE_RAW: &str = "client_certificate_raw"; | ||
pub const TLS_CLIENT_CERTIFICATE_BASE64: &str = "client_certificate_base64"; | ||
pub const TLS_CONNECT_CERTIFICATE_FILE: &str = "connect_certificate_file"; | ||
pub const TLS_CONNECT_CERTIFICATE_RAW: &str = "connect_certificate_raw"; | ||
pub const TLS_CONNECT_CERTIFICATE_BASE64: &str = "connect_certificate_base64"; | ||
|
||
pub const TLS_CLIENT_AUTH: &str = "client_auth"; | ||
pub const TLS_ENABLE_MTLS: &str = "enable_mtls"; | ||
|
||
pub const TLS_SERVER_NAME_VERIFICATION: &str = "server_name_verification"; | ||
pub const TLS_SERVER_NAME_VERIFICATION_DEFAULT: &str = "true"; | ||
pub const TLS_VERIFY_NAME_ON_CONNECT: &str = "verify_name_on_connect"; | ||
pub const TLS_VERIFY_NAME_ON_CONNECT_DEFAULT: &str = "true"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep I noticed it while doing the changes. I think in both QUIC and TLS we should use the default value when getting from the conf. I'll fix it |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,81 +62,81 @@ impl ConfigurationInspector<ZenohConfig> for TlsConfigurator { | |
_ => {} | ||
} | ||
|
||
match (c.server_private_key(), c.server_private_key_base64()) { | ||
match (c.listen_private_key(), c.listen_private_key_base64()) { | ||
(Some(_), Some(_)) => { | ||
bail!("Only one between 'server_private_key' and 'server_private_key_base64' can be present!") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error message |
||
} | ||
(Some(server_private_key), None) => { | ||
ps.push((TLS_SERVER_PRIVATE_KEY_FILE, server_private_key)); | ||
ps.push((TLS_LISTEN_PRIVATE_KEY_FILE, server_private_key)); | ||
} | ||
(None, Some(server_private_key)) => { | ||
ps.push(( | ||
TLS_SERVER_PRIVATE_KEY_BASE64, | ||
TLS_LISTEN_PRIVATE_KEY_BASE64, | ||
server_private_key.expose_secret(), | ||
)); | ||
} | ||
_ => {} | ||
} | ||
|
||
match (c.server_certificate(), c.server_certificate_base64()) { | ||
match (c.listen_certificate(), c.listen_certificate_base64()) { | ||
(Some(_), Some(_)) => { | ||
bail!("Only one between 'server_certificate' and 'server_certificate_base64' can be present!") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error message |
||
} | ||
(Some(server_certificate), None) => { | ||
ps.push((TLS_SERVER_CERTIFICATE_FILE, server_certificate)); | ||
ps.push((TLS_LISTEN_CERTIFICATE_FILE, server_certificate)); | ||
} | ||
(None, Some(server_certificate)) => { | ||
ps.push(( | ||
TLS_SERVER_CERTIFICATE_BASE64, | ||
TLS_LISTEN_CERTIFICATE_BASE64, | ||
server_certificate.expose_secret(), | ||
)); | ||
} | ||
_ => {} | ||
} | ||
|
||
if let Some(client_auth) = c.client_auth() { | ||
if let Some(client_auth) = c.enable_mtls() { | ||
match client_auth { | ||
true => ps.push((TLS_CLIENT_AUTH, "true")), | ||
false => ps.push((TLS_CLIENT_AUTH, "false")), | ||
true => ps.push((TLS_ENABLE_MTLS, "true")), | ||
false => ps.push((TLS_ENABLE_MTLS, "false")), | ||
}; | ||
} | ||
|
||
match (c.client_private_key(), c.client_private_key_base64()) { | ||
match (c.connect_private_key(), c.connect_private_key_base64()) { | ||
(Some(_), Some(_)) => { | ||
bail!("Only one between 'client_private_key' and 'client_private_key_base64' can be present!") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error message with new keys |
||
} | ||
(Some(client_private_key), None) => { | ||
ps.push((TLS_CLIENT_PRIVATE_KEY_FILE, client_private_key)); | ||
ps.push((TLS_CONNECT_PRIVATE_KEY_FILE, client_private_key)); | ||
} | ||
(None, Some(client_private_key)) => { | ||
ps.push(( | ||
TLS_CLIENT_PRIVATE_KEY_BASE64, | ||
TLS_CONNECT_PRIVATE_KEY_BASE64, | ||
client_private_key.expose_secret(), | ||
)); | ||
} | ||
_ => {} | ||
} | ||
|
||
match (c.client_certificate(), c.client_certificate_base64()) { | ||
match (c.connect_certificate(), c.connect_certificate_base64()) { | ||
(Some(_), Some(_)) => { | ||
bail!("Only one between 'client_certificate' and 'client_certificate_base64' can be present!") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error message with new keys |
||
} | ||
(Some(client_certificate), None) => { | ||
ps.push((TLS_CLIENT_CERTIFICATE_FILE, client_certificate)); | ||
ps.push((TLS_CONNECT_CERTIFICATE_FILE, client_certificate)); | ||
} | ||
(None, Some(client_certificate)) => { | ||
ps.push(( | ||
TLS_CLIENT_CERTIFICATE_BASE64, | ||
TLS_CONNECT_CERTIFICATE_BASE64, | ||
client_certificate.expose_secret(), | ||
)); | ||
} | ||
_ => {} | ||
} | ||
|
||
if let Some(server_name_verification) = c.server_name_verification() { | ||
if let Some(server_name_verification) = c.verify_name_on_connect() { | ||
match server_name_verification { | ||
true => ps.push((TLS_SERVER_NAME_VERIFICATION, "true")), | ||
false => ps.push((TLS_SERVER_NAME_VERIFICATION, "false")), | ||
true => ps.push((TLS_VERIFY_NAME_ON_CONNECT, "true")), | ||
false => ps.push((TLS_VERIFY_NAME_ON_CONNECT, "false")), | ||
}; | ||
} | ||
|
||
|
@@ -150,7 +150,7 @@ pub(crate) struct TlsServerConfig { | |
|
||
impl TlsServerConfig { | ||
pub async fn new(config: &Config<'_>) -> ZResult<TlsServerConfig> { | ||
let tls_server_client_auth: bool = match config.get(TLS_CLIENT_AUTH) { | ||
let tls_server_client_auth: bool = match config.get(TLS_ENABLE_MTLS) { | ||
Some(s) => s | ||
.parse() | ||
.map_err(|_| zerror!("Unknown client auth argument: {}", s))?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error message |
||
|
@@ -224,19 +224,19 @@ impl TlsServerConfig { | |
async fn load_tls_private_key(config: &Config<'_>) -> ZResult<Vec<u8>> { | ||
load_tls_key( | ||
config, | ||
TLS_SERVER_PRIVATE_KEY_RAW, | ||
TLS_SERVER_PRIVATE_KEY_FILE, | ||
TLS_SERVER_PRIVATE_KEY_BASE64, | ||
TLS_LISTEN_PRIVATE_KEY_RAW, | ||
TLS_LISTEN_PRIVATE_KEY_FILE, | ||
TLS_LISTEN_PRIVATE_KEY_BASE64, | ||
) | ||
.await | ||
} | ||
|
||
async fn load_tls_certificate(config: &Config<'_>) -> ZResult<Vec<u8>> { | ||
load_tls_certificate( | ||
config, | ||
TLS_SERVER_CERTIFICATE_RAW, | ||
TLS_SERVER_CERTIFICATE_FILE, | ||
TLS_SERVER_CERTIFICATE_BASE64, | ||
TLS_LISTEN_CERTIFICATE_RAW, | ||
TLS_LISTEN_CERTIFICATE_FILE, | ||
TLS_LISTEN_CERTIFICATE_BASE64, | ||
) | ||
.await | ||
} | ||
|
@@ -248,14 +248,14 @@ pub(crate) struct TlsClientConfig { | |
|
||
impl TlsClientConfig { | ||
pub async fn new(config: &Config<'_>) -> ZResult<TlsClientConfig> { | ||
let tls_client_server_auth: bool = match config.get(TLS_CLIENT_AUTH) { | ||
let tls_client_server_auth: bool = match config.get(TLS_ENABLE_MTLS) { | ||
Some(s) => s | ||
.parse() | ||
.map_err(|_| zerror!("Unknown client auth argument: {}", s))?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error message |
||
None => false, | ||
}; | ||
|
||
let tls_server_name_verification: bool = match config.get(TLS_SERVER_NAME_VERIFICATION) { | ||
let tls_server_name_verification: bool = match config.get(TLS_VERIFY_NAME_ON_CONNECT) { | ||
Some(s) => { | ||
let s: bool = s | ||
.parse() | ||
|
@@ -360,19 +360,19 @@ impl TlsClientConfig { | |
async fn load_tls_private_key(config: &Config<'_>) -> ZResult<Vec<u8>> { | ||
load_tls_key( | ||
config, | ||
TLS_CLIENT_PRIVATE_KEY_RAW, | ||
TLS_CLIENT_PRIVATE_KEY_FILE, | ||
TLS_CLIENT_PRIVATE_KEY_BASE64, | ||
TLS_CONNECT_PRIVATE_KEY_RAW, | ||
TLS_CONNECT_PRIVATE_KEY_FILE, | ||
TLS_CONNECT_PRIVATE_KEY_BASE64, | ||
) | ||
.await | ||
} | ||
|
||
async fn load_tls_certificate(config: &Config<'_>) -> ZResult<Vec<u8>> { | ||
load_tls_certificate( | ||
config, | ||
TLS_CLIENT_CERTIFICATE_RAW, | ||
TLS_CLIENT_CERTIFICATE_FILE, | ||
TLS_CLIENT_CERTIFICATE_BASE64, | ||
TLS_CONNECT_CERTIFICATE_RAW, | ||
TLS_CONNECT_CERTIFICATE_FILE, | ||
TLS_CONNECT_CERTIFICATE_BASE64, | ||
) | ||
.await | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
client
in comment.