simplify TLS.probe() modals

This commit is contained in:
nworbnhoj 2023-12-22 14:24:08 +11:00
parent 0ca24db2f0
commit 7d72387cb9
2 changed files with 22 additions and 20 deletions

View file

@ -1,7 +1,7 @@
{
"tls.check_trust_prompt": {
"en": "Do you trust any of these certificate authorities?",
"en-tts": "Do you trust any of these certificate authorities?"
"en": "Please select trusted certificate authorities.",
"en-tts": "Please select trusted certificate authorities."
},
"tls.cmd_help": {
"en": "Establishing an encrypted tls connection requires the host to provide a signed Certificate of identity. Each Certificate is signed for authenticity by a Certificate Authority. The CA's Certificate will in-turn be signed by yet another CA. These signed Certificates link into a chain of trust back to a trusted Root CA.\n\nTypically, this all happens automagically because many OS's & browsers incorporate a long list of trusted Root CA Certiicates. And this is OK because you trust the CA's that your OS trusts, right!\n\nOn Precursor, you must explicitly trust one or more root CA Certificates. You can:\nnet tls inspect <host>\n\tto trust a specific CA Certificate, or\nnet tls mozilla\n\tto trust all of the CA Certificates incporporated in the Firefox browser.",
@ -47,10 +47,6 @@
"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"

View file

@ -34,26 +34,32 @@ impl rustls::client::ServerCertVerifier for StifledCertificateVerification {
Err(Error::InvalidCertificate(e)) => {
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::UnknownIssuer => Ok(ServerCertVerified::assertion()),
CertificateError::NotValidYet => {
modals
.show_notification(t!("tls.probe_help_not_valid_yet", locales::LANG), None)
.show_notification(
t!("tls.probe_help_not_valid_yet", locales::LANG),
None,
)
.expect("modal failed");
Err(Error::InvalidCertificate(e))
}
_ => Err(Error::InvalidCertificate(e)),
_ => {
modals
.show_notification(
format!(
"{}\n{:?}",
t!("tls.probe_invalid_certificate", locales::LANG),
e
)
.as_str(),
None,
)
.expect("modal failed");
Err(Error::InvalidCertificate(e))
}
}
}
Err(e) => Err(e),