mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
update rustls_pemfile
This commit is contained in:
parent
372c43e538
commit
2c138fc0eb
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -495,7 +495,7 @@ dependencies = [
|
|||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"itertools 0.10.5",
|
"itertools 0.12.1",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lazycell",
|
"lazycell",
|
||||||
"proc-macro2 1.0.83",
|
"proc-macro2 1.0.83",
|
||||||
@ -5494,7 +5494,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
|
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"openssl-probe",
|
"openssl-probe",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile 1.0.4",
|
||||||
"schannel",
|
"schannel",
|
||||||
"security-framework",
|
"security-framework",
|
||||||
]
|
]
|
||||||
@ -5508,6 +5508,16 @@ dependencies = [
|
|||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-pemfile"
|
||||||
|
version = "2.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.22.1",
|
||||||
|
"rustls-pki-types",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-pki-types"
|
name = "rustls-pki-types"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
@ -6776,8 +6786,8 @@ version = "1.6.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
|
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 1.0.0",
|
||||||
"rand 0.7.3",
|
"rand 0.8.5",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -7292,7 +7302,7 @@ dependencies = [
|
|||||||
"ron",
|
"ron",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile 2.1.2",
|
||||||
"schnellru",
|
"schnellru",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -48,7 +48,7 @@ futures-util = { workspace = true }
|
|||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
quinn = { workspace = true }
|
quinn = { workspace = true }
|
||||||
rustls = { workspace = true }
|
rustls = { workspace = true }
|
||||||
rustls-pemfile = { version = "1", default-features = false }
|
rustls-pemfile = { version = "2", default-features = false, features = ["std"] }
|
||||||
atomicwrites = "0.4"
|
atomicwrites = "0.4"
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
chrono-tz = { workspace = true }
|
chrono-tz = { workspace = true }
|
||||||
|
@ -552,13 +552,19 @@ impl Server {
|
|||||||
rustls::PrivateKey(key)
|
rustls::PrivateKey(key)
|
||||||
} else {
|
} else {
|
||||||
debug!("convert pem key to der");
|
debug!("convert pem key to der");
|
||||||
let key = rustls_pemfile::read_all(&mut key.as_slice())?
|
let key = rustls_pemfile::read_all(&mut key.as_slice())
|
||||||
.into_iter()
|
|
||||||
.find_map(|item| match item {
|
.find_map(|item| match item {
|
||||||
Item::RSAKey(v) | Item::PKCS8Key(v) => Some(v),
|
Ok(Item::Pkcs1Key(v)) => Some(v.secret_pkcs1_der().into()),
|
||||||
Item::ECKey(_) => None,
|
Ok(Item::Pkcs8Key(v)) => Some(v.secret_pkcs8_der().into()),
|
||||||
Item::X509Certificate(_) => None,
|
Ok(Item::Sec1Key(_)) => None,
|
||||||
_ => None,
|
Ok(Item::Crl(_)) => None,
|
||||||
|
Ok(Item::Csr(_)) => None,
|
||||||
|
Ok(Item::X509Certificate(_)) => None,
|
||||||
|
Ok(_) => None,
|
||||||
|
Err(e) => {
|
||||||
|
tracing::warn!(?e, "error while reading key_file");
|
||||||
|
None
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.ok_or("No valid pem key in file")?;
|
.ok_or("No valid pem key in file")?;
|
||||||
rustls::PrivateKey(key)
|
rustls::PrivateKey(key)
|
||||||
@ -569,8 +575,15 @@ impl Server {
|
|||||||
vec![rustls::Certificate(cert_chain)]
|
vec![rustls::Certificate(cert_chain)]
|
||||||
} else {
|
} else {
|
||||||
debug!("convert pem cert to der");
|
debug!("convert pem cert to der");
|
||||||
let certs = rustls_pemfile::certs(&mut cert_chain.as_slice())?;
|
rustls_pemfile::certs(&mut cert_chain.as_slice())
|
||||||
certs.into_iter().map(rustls::Certificate).collect()
|
.filter_map(|item| match item {
|
||||||
|
Ok(cert) => Some(rustls::Certificate(cert.to_vec())),
|
||||||
|
Err(e) => {
|
||||||
|
tracing::warn!(?e, "error while reading cert_file");
|
||||||
|
None
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
};
|
};
|
||||||
let server_config = quinn::ServerConfig::with_single_cert(cert_chain, key)?;
|
let server_config = quinn::ServerConfig::with_single_cert(cert_chain, key)?;
|
||||||
Ok(server_config)
|
Ok(server_config)
|
||||||
|
Loading…
Reference in New Issue
Block a user