-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle is format changed from 'im:wireapp={input}' to 'im:wireapp=%40{input}@{domain}' * WireIdentity contains JWK thumbprint of the certificate public key * WireIdentity contains a validation status (Valid/Expired/Revoked)
- Loading branch information
Showing
15 changed files
with
503 additions
and
358 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use super::IdentityStatus; | ||
|
||
pub(crate) fn extract_status(cert: &x509_cert::TbsCertificate) -> IdentityStatus { | ||
if is_revoked(cert) { | ||
IdentityStatus::Revoked | ||
} else if !is_time_valid(cert) { | ||
IdentityStatus::Expired | ||
} else { | ||
IdentityStatus::Valid | ||
} | ||
} | ||
|
||
fn is_time_valid(cert: &x509_cert::TbsCertificate) -> bool { | ||
// 'not_before' < now < 'not_after' | ||
let x509_cert::time::Validity { not_before, not_after } = cert.validity; | ||
|
||
let now = fluvio_wasm_timer::SystemTime::now(); | ||
let Ok(now) = now.duration_since(fluvio_wasm_timer::UNIX_EPOCH) else { | ||
return false; | ||
}; | ||
|
||
let is_nbf = now >= not_before.to_unix_duration(); | ||
let is_naf = now < not_after.to_unix_duration(); | ||
is_nbf && is_naf | ||
} | ||
|
||
// TODO | ||
fn is_revoked(_cert: &x509_cert::TbsCertificate) -> bool { | ||
false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::{ | ||
error::CertificateError, | ||
prelude::{RustyAcmeError, RustyAcmeResult}, | ||
}; | ||
use jwt_simple::prelude::*; | ||
use rusty_jwt_tools::{ | ||
jwk::TryIntoJwk, | ||
prelude::{HashAlgorithm, JwkThumbprint}, | ||
}; | ||
use x509_cert::spki::SubjectPublicKeyInfoOwned; | ||
|
||
/// See: https://datatracker.ietf.org/doc/html/rfc8037#appendix-A.3 | ||
pub(crate) fn try_compute_jwk_canonicalized_thumbprint(cert: &x509_cert::TbsCertificate) -> RustyAcmeResult<String> { | ||
let jwk = try_into_jwk(&cert.subject_public_key_info)?; | ||
// Hash is always SHA-256 | ||
let thumbprint = JwkThumbprint::generate(&jwk, HashAlgorithm::SHA256)?; | ||
Ok(thumbprint.kid) | ||
} | ||
|
||
fn try_into_jwk(spki: &SubjectPublicKeyInfoOwned) -> RustyAcmeResult<Jwk> { | ||
let oid = oid_registry::Oid::new(std::borrow::Cow::Borrowed(spki.algorithm.oid.as_bytes())); | ||
|
||
// cannot pattern match oid_registry::Oid because it contains a Cow<'_> | ||
if oid == oid_registry::OID_SIG_ED25519 { | ||
Ok(Ed25519PublicKey::from_bytes(spki.subject_public_key.raw_bytes())?.try_into_jwk()?) | ||
} else if oid == oid_registry::OID_SIG_ECDSA_WITH_SHA256 { | ||
Ok(ES256PublicKey::from_bytes(spki.subject_public_key.raw_bytes())?.try_into_jwk()?) | ||
} else if oid == oid_registry::OID_SIG_ECDSA_WITH_SHA384 { | ||
Ok(ES384PublicKey::from_bytes(spki.subject_public_key.raw_bytes())?.try_into_jwk()?) | ||
} else { | ||
Err(RustyAcmeError::InvalidCertificate(CertificateError::InvalidPublicKey)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.