summaryrefslogtreecommitdiff
path: root/ext/net/ops_tls.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-04-18 18:21:08 +0100
committerGitHub <noreply@github.com>2024-04-18 11:21:08 -0600
commit6a09a16d710b2d7a9d39478e5bcbabb40919d657 (patch)
tree89d89485ec7c8c31fc8cf224995697919d9c8811 /ext/net/ops_tls.rs
parent5e2a747685490b31efa778241fccf938bd33722d (diff)
feat(ext/net): extract TLS key and certificate from interfaces (#23327)
Relands #23325
Diffstat (limited to 'ext/net/ops_tls.rs')
-rw-r--r--ext/net/ops_tls.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/net/ops_tls.rs b/ext/net/ops_tls.rs
index c0ac31586..487adf3bc 100644
--- a/ext/net/ops_tls.rs
+++ b/ext/net/ops_tls.rs
@@ -10,6 +10,7 @@ use crate::tcp::TcpListener;
use crate::DefaultTlsOptions;
use crate::NetPermissions;
use crate::UnsafelyIgnoreCertificateErrors;
+use deno_core::anyhow::anyhow;
use deno_core::error::bad_resource;
use deno_core::error::custom_error;
use deno_core::error::generic_error;
@@ -448,18 +449,13 @@ where
.with_no_client_auth();
let mut tls_config = match keys {
- TlsKeys::Null => {
- unreachable!()
- }
- TlsKeys::Static(TlsKey(cert, key)) => {
- tls_config.with_single_cert(cert.clone(), key.clone())
- }
+ TlsKeys::Null => Err(anyhow!("Deno.listenTls requires a key")),
+ TlsKeys::Static(TlsKey(cert, key)) => tls_config
+ .with_single_cert(cert.clone(), key.clone())
+ .map_err(|e| anyhow!(e)),
}
.map_err(|e| {
- custom_error(
- "InvalidData",
- format!("Error creating TLS certificate: {:?}", e),
- )
+ custom_error("InvalidData", "Error creating TLS certificate").context(e)
})?;
if let Some(alpn_protocols) = args.alpn_protocols {