Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TLS加密的PostgreSQL连接不可能_Postgresql_Rust_Tls1.2_Rust Tokio_Tokio Postgres - Fatal编程技术网

TLS加密的PostgreSQL连接不可能

TLS加密的PostgreSQL连接不可能,postgresql,rust,tls1.2,rust-tokio,tokio-postgres,Postgresql,Rust,Tls1.2,Rust Tokio,Tokio Postgres,我想使用Tokio作为框架,Deadpool作为连接池,rustls作为TLS库,建立到PostgreSQL 11数据库的TLS加密连接 我开发/修改了代码: let pool=if let Some(ca\u cert)=settings.db\u ca\u cert{ 让mut tls_config=ClientConfig::new(); 让证书文件=文件::打开(&ca证书)?; 让mut buf=BufReader::new(证书文件); tls_config.root_store.a

我想使用Tokio作为框架,Deadpool作为连接池,rustls作为TLS库,建立到PostgreSQL 11数据库的TLS加密连接

我开发/修改了代码:

let pool=if let Some(ca\u cert)=settings.db\u ca\u cert{
让mut tls_config=ClientConfig::new();
让证书文件=文件::打开(&ca证书)?;
让mut buf=BufReader::new(证书文件);
tls_config.root_store.add_pem_file(&mut buf).map_err(| | |{
anyhow::anyhow!(“未能读取数据库根证书:{}”,ca_证书)
})?;
让tls=makerustlsconnet::new(tls\u config);
设置.pg.create_pool(tls)?
}否则{
设置.pg.create_pool(NoTls)?
};
我的测试场景取自:

  • PostgreSQL 11 docker容器(包括打开的TLS)
  • TLS已通过psql客户端成功测试
我现在收到以下错误消息,无法解释问题。我已经检查了访问权限和其他参数

/usr/local/bin/cargo run--color=始终
在0.20秒内完成开发[未优化+调试信息]目标
正在运行'target/debug/tokio postgres rustls连接池演示`
DEBUG tokio_postgres_rustls_connection_pool_demo>设置:设置{pg:Config{user:Some(“postgres”)、密码:Some(“postgres”)、数据库名:Some(“postgres”)、选项:Some(“sslrootcert=/xxx/tokio postgres rustls connection pool demo/docker/files/cert/ca.pem”)、应用程序名:无、ssl模式:无、主机:Some(“127.0.0.1”),主机:无,端口:某些(6432),端口:无,连接\u超时:无,保留有效期:无,保留有效期\u空闲:无,目标\u会话\u属性:无,通道\u绑定:无,管理器:无,池:无},db\u ca\u证书:无}
错误:后端(错误{kind:Connect,原因:Some(操作系统{code:2,kind:NotFound,消息:“没有这样的文件或目录”})})
我查看了数据库的日志,发现了以下错误:

[86]日志:XX000:无法接受SSL连接:成功
[86]位置:be_tls_open_server,be secure openssl。c:408

如何解决此问题?

可能证书路径错误。我已检查了该opportunity。路径和访问权限正确。在您的程序上运行
strace
,查找错误。很难回答您的问题,因为它不包含错误。我们无法说出代码中存在哪些板条箱(及其版本)、类型、特征、字段等。如果您试图重现您的错误(如果可能的话),或者在全新的货运项目中,那么我们将更容易帮助您,然后您的问题将包括附加信息。您可以使用以下方法减少在此处发布的原始代码。谢谢请将您的问题添加到问题本身,并添加到存储库的链接。