其实就是用hyper请求https://httpbin.org,服务端验证了证书,而客户端没有使用证书。所以报错,报错如下:
hyper::Error(Connect, ConnectError { error: Error { code: ErrorCode(5), cause: Some(Ssl(ErrorStack([Error { code: 2147483650, library: "system library", function: "file_open ", file: "providers\implementations\storemgmt\file_store.c", line: 267, data: "calling stat(D:\code\github\cctv\target\debug\build\openssl-sys-ff4a75a3 fbf9373f\out\openssl-build\install\SYSANAGER:[OPENSSL]/certs)" }, Error { code: 369623308, library: "STORE routines", function: "inner_loader_fetch", reason: "unsupporte d", file: "crypto\store\store_meth.c", line: 353, data: "No store loader found. For standard store loaders you need at least one of the default or base providers available . Did you forget to load them? Info: Global default library context, Scheme (D : 0), Properties ()" }, Error { code: 2147483650, library: "system library", function: " file_open", file: "providers\implementations\storemgmt\file_store.c", line: 267, data: "calling stat(D:\code\github\cctv\target\debug\build\openssl-sys -ff4a75a3fbf9373f\out\openssl-build\install\SYSANAGER:[OPENSSL]/certs)" }, Error { code: 369623308, library: "STORE routines", function: "inner_loader_fetch", reason: "u nsupported", file: "crypto\store\store_meth.c", line: 353, data: "No store loader found. For standard store loaders you need at least one of the default or base providers available. Did you forget to load them? Info: Global default library context, Scheme (D : 0), Properties ()" }, Error { code: 2147483650, library: "system library", fu nction: "file_open", file: "providers\implementations\storemgmt\file_store.c", line: 267, data: "calling stat(D:\code\github\cctv\target\debug\build\op enssl-sys-ff4a75a3fbf9373f\out\openssl-build\install\SYSANAGER:[OPENSSL]/certs)" }, Error { code: 369623308, library: "STORE routines", function: "inner_loader_fetch", r eason: "unsupported", file: "crypto\store\store_meth.c", line: 353, data: "No store loader found. For standard store loaders you need at least one of the default or base p roviders available. Did you forget to load them? Info: Global default library context, Scheme (D : 0), Properties ()" }, Error { code: 2147483650, library: "system lib rary", function: "file_open", file: "providers\implementations\storemgmt\file_store.c", line: 267, data: "calling stat(D:\code\github\cctv\target\debug\ build\openssl-sys-ff4a75a3fbf9373f\out\openssl-build\install\SYSANAGER:[OPENSSL]/certs)" }, Error { code: 369623308, library: "STORE routines", function: "inner_loader_ fetch", reason: "unsupported", file: "crypto\store\store_meth.c", line: 353, data: "No store loader found. For standard store loaders you need at least one of the default or base providers available. Did you forget to load them? Info: Global default library context, Scheme (D : 0), Properties ()" }, Error { code: 2147483650, library: "s ystem library", function: "file_open", file: "providers\implementations\storemgmt\file_store.c", line: 267, data: "calling stat(D:\code\github\cctv\target \debug\build\openssl-sys-ff4a75a3fbf9373f\out\openssl-build\install\SYSANAGER:[OPENSSL]/certs)" }, Error { code: 369623308, library: "STORE routines", function: "inne r_loader_fetch", reason: "unsupported", file: "crypto\store\store_meth.c", line: 353, data: "No store loader found. For standard store loaders you need at least one of the default or base providers available. Did you forget to load them? Info: Global default library context, Scheme (D : 0), Properties ()" }, Error { code: 167772294, lib rary: "SSL routines", function: "tls_post_process_server_certificate", reason: "certificate verify failed", file: "ssl\statem\statem_clnt.c", line: 1890 }]))) }, verify_re sult: X509VerifyResult { code: 20, error: "unable to get local issuer certificate" } })
现在就是判断出现证书问题的时候,做一个任务。现在无法判断这个Error是证书出错了。hyper包装了好几层,里面还有部分是c++的error。
评论区
写评论刚把这个问题解决了,自己回复一下,用的是hyper+openssl这个crate来发送https的请求。
let res = client.request(request).await.map_err(|e| { let message = e.to_string(); if let Some(e1) = e.into_cause() { if let Some(e2) = e1.source() { let tt = e2.downcast_ref::ssl::Error(); if let Some(ssl_error) = tt { if ssl_error.code() == ssl::ErrorCode::SYSCALL { return anyhow!("Please use a valid ssl certificate or add the flag '-k' to skip the certificate validation."); } } } } return anyhow!("{}", message); })?;