Upgrade example to rcgen 0.13
This commit is contained in:
parent
f90227429d
commit
7648ebb509
|
@ -38,7 +38,7 @@ thiserror = "1.0.30"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
anyhow = "1.0.66"
|
anyhow = "1.0.66"
|
||||||
clap = { version = "4.0.29", features = ["derive"] }
|
clap = { version = "4.0.29", features = ["derive"] }
|
||||||
rcgen = { version = "0.12", default-features = false, features = ["pem"] }
|
rcgen = { version = "0.13", default-features = false, features = ["pem"] }
|
||||||
tokio = { version = "1.22.0", features = ["macros", "rt", "rt-multi-thread", "time"] }
|
tokio = { version = "1.22.0", features = ["macros", "rt", "rt-multi-thread", "time"] }
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-subscriber = "0.3.16"
|
tracing-subscriber = "0.3.16"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{io, time::Duration};
|
use std::{io, time::Duration};
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use rcgen::{Certificate, CertificateParams, DistinguishedName};
|
use rcgen::{CertificateParams, DistinguishedName, KeyPair};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
|
@ -128,14 +128,14 @@ async fn main() -> anyhow::Result<()> {
|
||||||
// If the order is ready, we can provision the certificate.
|
// If the order is ready, we can provision the certificate.
|
||||||
// Use the rcgen library to create a Certificate Signing Request.
|
// Use the rcgen library to create a Certificate Signing Request.
|
||||||
|
|
||||||
let mut params = CertificateParams::new(names.clone());
|
let mut params = CertificateParams::new(names.clone())?;
|
||||||
params.distinguished_name = DistinguishedName::new();
|
params.distinguished_name = DistinguishedName::new();
|
||||||
let cert = Certificate::from_params(params).unwrap();
|
let private_key = KeyPair::generate()?;
|
||||||
let csr = cert.serialize_request_der()?;
|
let csr = params.serialize_request(&private_key)?;
|
||||||
|
|
||||||
// Finalize the order and print certificate chain, private key and account credentials.
|
// Finalize the order and print certificate chain, private key and account credentials.
|
||||||
|
|
||||||
order.finalize(&csr).await.unwrap();
|
order.finalize(csr.der()).await.unwrap();
|
||||||
let cert_chain_pem = loop {
|
let cert_chain_pem = loop {
|
||||||
match order.certificate().await.unwrap() {
|
match order.certificate().await.unwrap() {
|
||||||
Some(cert_chain_pem) => break cert_chain_pem,
|
Some(cert_chain_pem) => break cert_chain_pem,
|
||||||
|
@ -144,7 +144,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("certficate chain:\n\n{}", cert_chain_pem);
|
info!("certficate chain:\n\n{}", cert_chain_pem);
|
||||||
info!("private key:\n\n{}", cert.serialize_private_key_pem());
|
info!("private key:\n\n{}", private_key.serialize_pem());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue