Skip to content

Commit

Permalink
make necessary rcgen api changes to add compatibility with new version
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Wrock <[email protected]>
  • Loading branch information
mwrock committed May 21, 2024
1 parent 36b5992 commit 5afb0c2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions components/core/src/tls/ctl_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use crate::{crypto::keys::NamedRevision,
tls::rustls_wrapper::{self,
Error as RustlsReadersError}};
use rcgen::{Certificate as RcgenCertificate,
CertificateParams,
use rcgen::{CertificateParams,
DistinguishedName,
DnType,
Error as RcgenError,
KeyPair,
PKCS_ECDSA_P256_SHA256};
use rustls::{Certificate,
PrivateKey,
Expand Down Expand Up @@ -43,16 +43,16 @@ pub fn generate_self_signed_certificate_and_key(subject_alternate_name: &DnsName
-> Result<(), Error> {
let mut params =
CertificateParams::new(vec![Into::<&str>::into(subject_alternate_name.as_ref()).to_string(),
"localhost".to_string(),]);
"localhost".to_string(),])?;
let mut distinguished_name = DistinguishedName::new();
distinguished_name.push(DnType::OrganizationName,
"Habitat Supervisor Control Gateway");
params.distinguished_name = distinguished_name;
params.alg = &PKCS_ECDSA_P256_SHA256;

let certificate = RcgenCertificate::from_params(params)?;
let crt = certificate.serialize_pem()?;
let key = certificate.serialize_private_key_pem();
let key_pair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256)?;
let certificate = params.self_signed(&key_pair)?;
let crt = certificate.pem();
let key = key_pair.serialize_pem();

fs::create_dir_all(&path)?;
let named_revision = NamedRevision::new(NAME_PREFIX.to_string());
Expand Down

0 comments on commit 5afb0c2

Please sign in to comment.