International Domain Names (IDN) support (closes #207)
This commit is contained in:
5
crates/common/src/cache/principals.rs
vendored
5
crates/common/src/cache/principals.rs
vendored
@@ -41,9 +41,14 @@ use store::{
|
||||
};
|
||||
use trc::{AddContext, StoreEvent};
|
||||
use types::id::Id;
|
||||
use utils::DomainPart;
|
||||
|
||||
impl Server {
|
||||
pub async fn domain(&self, domain: &str) -> trc::Result<Option<Arc<DomainCache>>> {
|
||||
let Some(domain) = domain.to_ascii_domain() else {
|
||||
return Ok(None);
|
||||
};
|
||||
let domain = domain.as_ref();
|
||||
let domain_names = &self.inner.cache.domain_names;
|
||||
|
||||
if let Some(domain_id) = domain_names.get(domain) {
|
||||
|
||||
@@ -189,6 +189,17 @@ pub(crate) fn build_certified_key(
|
||||
pub(crate) fn build_self_signed_cert(
|
||||
domains: impl Into<Vec<String>>,
|
||||
) -> Result<CertifiedKey, String> {
|
||||
let domains = domains
|
||||
.into()
|
||||
.into_iter()
|
||||
.map(|domain| {
|
||||
if domain.is_ascii() {
|
||||
domain
|
||||
} else {
|
||||
idna::domain_to_ascii(&domain).unwrap_or(domain)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let rcgen::CertifiedKey { cert, signing_key } = generate_simple_self_signed(domains)
|
||||
.map_err(|err| format!("Failed to generate self-signed certificate: {err}",))?;
|
||||
build_certified_key(
|
||||
|
||||
Reference in New Issue
Block a user