Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e15c42

Browse files
committed
fix
1 parenta21f53d commit2e15c42

File tree

4 files changed

+147
-68
lines changed

4 files changed

+147
-68
lines changed

‎Cargo.lock‎

Lines changed: 104 additions & 29 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎stdlib/Cargo.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ openssl-probe = { version = "0.1.5", optional = true }
119119
foreign-types-shared = {version ="0.1.1",optional =true }
120120

121121
# Rustls dependencies (optional, for ssl-rustls feature)
122-
rustls = {version ="0.23",default-features =false,features = ["std","tls12","ring"],optional =true }
123-
rustls-native-certs = {version ="0.7",optional =true }
124-
rustls-pemfile = {version ="2.0",optional =true }
125-
rustls-platform-verifier = {version ="0.3",optional =true }
122+
rustls = {version ="0.23.35",default-features =false,features = ["std","tls12","ring"],optional =true }
123+
rustls-native-certs = {version ="0.8",optional =true }
124+
rustls-pemfile = {version ="2.2",optional =true }
125+
rustls-platform-verifier = {version ="0.6",optional =true }
126126
x509-cert = {version ="0.2",features = ["pem","builder"],optional =true }
127127
x509-parser = {version ="0.16",optional =true }
128128
der = {version ="0.7",features = ["alloc","oid"],optional =true }

‎stdlib/src/ssl.rs‎

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,23 +1421,21 @@ mod _ssl {
14211421
let environ = os_module.get_attr("environ", vm)?;
14221422

14231423
// Try SSL_CERT_FILE first
1424-
ifletOk(cert_file) =Self::get_env_path(&environ,"SSL_CERT_FILE", vm){
1425-
ifPath::new(&cert_file).exists(){
1426-
ifletOk(stats) = loader.load_from_file(&cert_file){
1427-
self.update_cert_stats(stats);
1428-
returnOk(true);
1429-
}
1430-
}
1424+
ifletOk(cert_file) =Self::get_env_path(&environ,"SSL_CERT_FILE", vm)
1425+
&&Path::new(&cert_file).exists()
1426+
&&letOk(stats) = loader.load_from_file(&cert_file)
1427+
{
1428+
self.update_cert_stats(stats);
1429+
returnOk(true);
14311430
}
14321431

14331432
// Try SSL_CERT_DIR (only if SSL_CERT_FILE didn't work)
1434-
ifletOk(cert_dir) =Self::get_env_path(&environ,"SSL_CERT_DIR", vm){
1435-
ifPath::new(&cert_dir).is_dir(){
1436-
ifletOk(stats) = loader.load_from_dir(&cert_dir){
1437-
self.update_cert_stats(stats);
1438-
returnOk(true);
1439-
}
1440-
}
1433+
ifletOk(cert_dir) =Self::get_env_path(&environ,"SSL_CERT_DIR", vm)
1434+
&&Path::new(&cert_dir).is_dir()
1435+
&&letOk(stats) = loader.load_from_dir(&cert_dir)
1436+
{
1437+
self.update_cert_stats(stats);
1438+
returnOk(true);
14411439
}
14421440

14431441
Ok(false)
@@ -1454,23 +1452,29 @@ mod _ssl {
14541452
store:&mut rustls::RootCertStore,
14551453
vm:&VirtualMachine,
14561454
) ->PyResult<()>{
1457-
match rustls_native_certs::load_native_certs(){
1458-
Ok(certs) =>{
1459-
for certin certs{
1460-
let is_ca = cert::is_ca_certificate(cert.as_ref());
1461-
if store.add(cert).is_ok(){
1462-
*self.x509_cert_count.write() +=1;
1463-
if is_ca{
1464-
*self.ca_cert_count.write() +=1;
1465-
}
1466-
}
1455+
let result = rustls_native_certs::load_native_certs();
1456+
1457+
// Load successfully found certificates
1458+
for certin result.certs{
1459+
let is_ca = cert::is_ca_certificate(cert.as_ref());
1460+
if store.add(cert).is_ok(){
1461+
*self.x509_cert_count.write() +=1;
1462+
if is_ca{
1463+
*self.ca_cert_count.write() +=1;
14671464
}
1468-
Ok(())
1469-
}
1470-
Err(e) =>{
1471-
Err(vm.new_os_error(format!("Failed to load native certificates: {}", e)))
14721465
}
14731466
}
1467+
1468+
// If there were errors but some certs loaded, just continue
1469+
// If NO certs loaded and there were errors, report the first error
1470+
if*self.x509_cert_count.read() ==0 && !result.errors.is_empty(){
1471+
returnErr(vm.new_os_error(format!(
1472+
"Failed to load native certificates: {}",
1473+
result.errors[0]
1474+
)));
1475+
}
1476+
1477+
Ok(())
14741478
}
14751479

14761480
#[pymethod]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp