mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
introduce tls probe help modals
- invalid certificate modal - unknown issuer modal - not valid yet modal
This commit is contained in:
parent
492d089d5c
commit
7e485885b7
2 changed files with 39 additions and 2 deletions
|
|
@ -43,6 +43,18 @@
|
||||||
"en": "failed to create server name from",
|
"en": "failed to create server name from",
|
||||||
"en-tts": "failed to create server name from"
|
"en-tts": "failed to create server name from"
|
||||||
},
|
},
|
||||||
|
"tls.probe_invalid_certificate": {
|
||||||
|
"en": "Invalid certificate : ",
|
||||||
|
"en-tts": "Invalid certificate : "
|
||||||
|
},
|
||||||
|
"tls.probe_help_unknown_issuer": {
|
||||||
|
"en": "you may choose to trust a known CA",
|
||||||
|
"en-tts": "you may choose to trust a known CA"
|
||||||
|
},
|
||||||
|
"tls.probe_help_not_valid_yet": {
|
||||||
|
"en": "error maybe caused by an improperly set clock",
|
||||||
|
"en-tts": "error maybe caused by an improperly set clock"
|
||||||
|
},
|
||||||
"tls.probe_done": {
|
"tls.probe_done": {
|
||||||
"en": "trusted CA's",
|
"en": "trusted CA's",
|
||||||
"en-tts": "trusted CA's"
|
"en-tts": "trusted CA's"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
|
use locales::t;
|
||||||
|
use modals::Modals;
|
||||||
use rustls::client::{ServerCertVerified, WebPkiVerifier};
|
use rustls::client::{ServerCertVerified, WebPkiVerifier};
|
||||||
use rustls::{CertificateError, Error, RootCertStore};
|
use rustls::{CertificateError, Error, RootCertStore};
|
||||||
|
use xous_names::XousNames;
|
||||||
|
|
||||||
pub struct StifledCertificateVerification {
|
pub struct StifledCertificateVerification {
|
||||||
pub roots: RootCertStore,
|
pub roots: RootCertStore,
|
||||||
|
|
@ -28,8 +31,30 @@ impl rustls::client::ServerCertVerifier for StifledCertificateVerification {
|
||||||
now,
|
now,
|
||||||
) {
|
) {
|
||||||
Ok(ok) => Ok(ok),
|
Ok(ok) => Ok(ok),
|
||||||
Err(Error::InvalidCertificate(CertificateError::UnknownIssuer)) => {
|
Err(Error::InvalidCertificate(e)) => {
|
||||||
Ok(ServerCertVerified::assertion())
|
let xns = XousNames::new().unwrap();
|
||||||
|
let modals = Modals::new(&xns).unwrap();
|
||||||
|
modals
|
||||||
|
.show_notification(
|
||||||
|
format!("{}\n{:?}", t!("tls.probe_invalid_certificate", locales::LANG), e).as_str(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.expect("modal failed");
|
||||||
|
match e {
|
||||||
|
CertificateError::UnknownIssuer => {
|
||||||
|
modals
|
||||||
|
.show_notification(t!("tls.probe_help_unknown_issuer", locales::LANG), None)
|
||||||
|
.expect("modal failed");
|
||||||
|
Ok(ServerCertVerified::assertion())
|
||||||
|
}
|
||||||
|
CertificateError::NotValidYet => {
|
||||||
|
modals
|
||||||
|
.show_notification(t!("tls.probe_help_not_valid_yet", locales::LANG), None)
|
||||||
|
.expect("modal failed");
|
||||||
|
Err(Error::InvalidCertificate(e))
|
||||||
|
}
|
||||||
|
_ => Err(Error::InvalidCertificate(e)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue