mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(runtime/tls): remove unnecessary clone calls (#9429)
This commit is contained in:
parent
a6723fafc5
commit
a601d94aa1
1 changed files with 8 additions and 10 deletions
|
@ -101,18 +101,17 @@ async fn op_start_tls(
|
|||
) -> Result<Value, AnyError> {
|
||||
let args: StartTLSArgs = serde_json::from_value(args)?;
|
||||
let rid = args.rid as u32;
|
||||
let cert_file = args.cert_file.clone();
|
||||
|
||||
let mut domain = args.hostname;
|
||||
let mut domain = args.hostname.as_str();
|
||||
if domain.is_empty() {
|
||||
domain.push_str("localhost");
|
||||
domain = "localhost";
|
||||
}
|
||||
{
|
||||
super::check_unstable2(&state, "Deno.startTls");
|
||||
let s = state.borrow();
|
||||
let permissions = s.borrow::<Permissions>();
|
||||
permissions.check_net(&(&domain, Some(0)))?;
|
||||
if let Some(path) = cert_file.clone() {
|
||||
if let Some(path) = &args.cert_file {
|
||||
permissions.check_read(Path::new(&path))?;
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +133,7 @@ async fn op_start_tls(
|
|||
config
|
||||
.root_store
|
||||
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
||||
if let Some(path) = cert_file {
|
||||
if let Some(path) = args.cert_file {
|
||||
let key_file = File::open(path)?;
|
||||
let reader = &mut BufReader::new(key_file);
|
||||
config.root_store.add_pem_file(reader).unwrap();
|
||||
|
@ -172,18 +171,17 @@ async fn op_connect_tls(
|
|||
_zero_copy: BufVec,
|
||||
) -> Result<Value, AnyError> {
|
||||
let args: ConnectTLSArgs = serde_json::from_value(args)?;
|
||||
let cert_file = args.cert_file.clone();
|
||||
{
|
||||
let s = state.borrow();
|
||||
let permissions = s.borrow::<Permissions>();
|
||||
permissions.check_net(&(&args.hostname, Some(args.port)))?;
|
||||
if let Some(path) = cert_file.clone() {
|
||||
if let Some(path) = &args.cert_file {
|
||||
permissions.check_read(Path::new(&path))?;
|
||||
}
|
||||
}
|
||||
let mut domain = args.hostname.clone();
|
||||
let mut domain = args.hostname.as_str();
|
||||
if domain.is_empty() {
|
||||
domain.push_str("localhost");
|
||||
domain = "localhost";
|
||||
}
|
||||
|
||||
let addr = resolve_addr(&args.hostname, args.port)
|
||||
|
@ -198,7 +196,7 @@ async fn op_connect_tls(
|
|||
config
|
||||
.root_store
|
||||
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
||||
if let Some(path) = cert_file {
|
||||
if let Some(path) = args.cert_file {
|
||||
let key_file = File::open(path)?;
|
||||
let reader = &mut BufReader::new(key_file);
|
||||
config.root_store.add_pem_file(reader).unwrap();
|
||||
|
|
Loading…
Reference in a new issue