Skip to content

Commit

Permalink
Added TODO marks for future enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 22, 2024
1 parent 7234398 commit 883da06
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rust/agama-server/src/cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ use openssl::x509::extension::{
};
use openssl::x509::{X509NameBuilder, X509};

// TODO: move the certificate related functions into a struct
//
// struct Certificate {
// certificate: X509,
// key: PKey<Private>,
// }
//
// impl Certificate {
// // read from file, support some default location
// // (like /etc/agama.d/ssl/{certificate,key}.pem ?)
// pub read(cert: &str, key: &str) -> Result<Self>;
// // generate a self-signed certificate
// pub new() -> Self
// // dump to file
// pub write(...)
// }

/// Generates a self-signed SSL certificate
/// see https://github.com/sfackler/rust-openssl/blob/master/openssl/examples/mk_certs.rs
pub fn create_certificate() -> Result<(X509, PKey<Private>), ErrorStack> {
Expand Down Expand Up @@ -48,8 +65,11 @@ pub fn create_certificate() -> Result<(X509, PKey<Private>), ErrorStack> {
builder.append_extension(
SubjectAlternativeName::new()
// use the default Agama host name
// TODO: use the gethostname crate and use the current real hostname
.dns("agama")
// use the default name for the mDNS/Avahi
// TODO: check which name is actually used by mDNS, to avoid
// conflicts it might actually use something like agama-2.local
.dns("agama.local")
.build(&builder.x509v3_context(None, None))?,
)?;
Expand Down

0 comments on commit 883da06

Please sign in to comment.