我一直在用 Rust 编写一个客户端,它向带有客户端证书(Pkcs12)的服务器发出请求。尽管已经回答了 How to make a request with client certificate in Rust,但代码并没有按原样编译。如果我进行一些修改,例如替换“?” 通过调用 unwrap() 函数,
代码:
let tls_conn = TlsConnector::builder().unwrap()
.identity(cert).unwrap()
.build().unwrap();
错误:
let tls_conn = TlsConnector::builder().unwrap()
| ____________________^
18 | | .identity(cert).unwrap()
| |________________________________^ cannot move out of borrowed content.
我重写了上面的代码行并将其分解为多行以进行调试:
let ref mut init_tls_conn_builder = TlsConnector::builder().unwrap();
let ref mut tls_conn_builder = init_tls_conn_builder.identity(cert).unwrap();
let tls_conn = tls_conn_builder.build().unwrap();
我收到如下错误:
let tls_conn = tls_conn_builder.build().unwrap();
| ^^^^^^^^^^^^^^^^ cannot move out of borrowed content.
我是 Rust 新手并寻求帮助,谁能分享一个编译的示例代码?