"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/interface/verifycertdialog.cpp" between
FileZilla_3.48.0_src.tar.bz2 and FileZilla_3.48.1_src.tar.bz2

About: FileZilla is a fast and feature-rich cross-platform FTP, FTPS and SFTP client with an intuitive graphical user interface.

verifycertdialog.cpp  (FileZilla_3.48.0_src.tar.bz2):verifycertdialog.cpp  (FileZilla_3.48.1_src.tar.bz2)
#include <filezilla.h> #include <filezilla.h>
#include "filezillaapp.h" #include "filezillaapp.h"
#include "verifycertdialog.h" #include "verifycertdialog.h"
#include "dialogex.h" #include "dialogex.h"
#include "ipcmutex.h" #include "ipcmutex.h"
#include "Options.h" #include "Options.h"
#include "timeformatting.h" #include "timeformatting.h"
#include "themeprovider.h"
#include "xrc_helper.h" #include "xrc_helper.h"
#include <libfilezilla/iputils.hpp> #include <libfilezilla/iputils.hpp>
#include <wx/gbsizer.h>
#include <wx/scrolwin.h> #include <wx/scrolwin.h>
#include <wx/statbox.h> #include <wx/statbox.h>
CertStore::CertStore() CertStore::CertStore()
: m_xmlFile(wxGetApp().GetSettingsFile(L"trustedcerts")) : m_xmlFile(wxGetApp().GetSettingsFile(L"trustedcerts"))
{ {
} }
bool CertStore::IsTrusted(fz::tls_session_info const& info) bool CertStore::IsTrusted(fz::tls_session_info const& info)
{ {
skipping to change at line 354 skipping to change at line 356
m_xmlFile.Save(true); m_xmlFile.Save(true);
} }
} }
// A host can't be both trusted and insecure // A host can't be both trusted and insecure
insecureHosts_.erase(std::make_tuple(cert.host, cert.port)); insecureHosts_.erase(std::make_tuple(cert.host, cert.port));
trustedCerts_.emplace_back(std::move(cert)); trustedCerts_.emplace_back(std::move(cert));
} }
struct CVerifyCertDialog::impl final
{
std::vector<fz::x509_certificate> certificates_;
wxCheckBox* san_trust_{};
wxCheckBox* always_{};
wxStaticText* validity_{};
wxStaticText* serial_{};
wxStaticText* pubkey_algo_{};
wxStaticText* signature_algo_{};
wxStaticText* fingerprint_sha1_{};
wxStaticText* fingerprint_sha256_{};
wxScrolledWindow* certPanel_{};
wxFlexGridSizer* certSizer_{};
wxFlexGridSizer* subjectSizer_{};
wxFlexGridSizer* issuerSizer_{};
};
CVerifyCertDialog::CVerifyCertDialog()
: impl_(std::make_unique<impl>())
{
}
CVerifyCertDialog::~CVerifyCertDialog()
{
}
bool CVerifyCertDialog::DisplayCert(fz::x509_certificate const& cert) bool CVerifyCertDialog::DisplayCert(fz::x509_certificate const& cert)
{ {
bool warning = false; std::wstring const sha256 = fz::to_wstring_from_utf8(cert.get_fingerprint
if (!cert.get_activation_time().empty()) { _sha256());
if (cert.get_activation_time() > fz::datetime::now()) { impl_->fingerprint_sha256_->SetLabel(sha256.substr(0, sha256.size() / 2 +
SetChildLabel(XRCID("ID_ACTIVATION_TIME"), wxString::Form 1) + L"\n" + sha256.substr(sha256.size() / 2 + 1));
at(_("%s - Not yet valid!"), CTimeFormat::Format(cert.get_activation_time()))); impl_->fingerprint_sha1_->SetLabel(fz::to_wstring_from_utf8(cert.get_fing
xrc_call(*this, "ID_ACTIVATION_TIME", &wxWindow::SetForeg erprint_sha1()));
roundColour, wxColour(255, 0, 0));
warning = true; bool valid_date{};
} wxString label;
else { if (!cert.get_activation_time() || !cert.get_expiration_time()) {
SetChildLabel(XRCID("ID_ACTIVATION_TIME"), CTimeFormat::F label = _("Invalid date");
ormat(cert.get_activation_time()));
xrc_call(*this, "ID_ACTIVATION_TIME", &wxWindow::SetForeg
roundColour, wxColour());
}
} }
else { else {
warning = true; // @translator: Placeholders will be filled with dates
SetChildLabel(XRCID("ID_ACTIVATION_TIME"), _("Invalid date")); label = wxString::Format(_("From %s to %s"), CTimeFormat::Format(
} cert.get_activation_time()), CTimeFormat::Format(cert.get_expiration_time()));
if (!cert.get_expiration_time().empty()) { if (cert.get_activation_time() > fz::datetime::now()) {
if (cert.get_expiration_time() < fz::datetime::now()) { label += L" - ";
SetChildLabel(XRCID("ID_EXPIRATION_TIME"), wxString::Form label += _("Not yet valid!");
at(_("%s - Certificate expired!"), CTimeFormat::Format(cert.get_expiration_time( }
)))); else if (cert.get_expiration_time() < fz::datetime::now()) {
xrc_call(*this, "ID_EXPIRATION_TIME", &wxWindow::SetForeg label += L" - ";
roundColour, wxColour(255, 0, 0)); label += _("Expired!");
warning = true;
} }
else { else {
SetChildLabel(XRCID("ID_EXPIRATION_TIME"), CTimeFormat::F valid_date = true;
ormat(cert.get_expiration_time()));
xrc_call(*this, "ID_EXPIRATION_TIME", &wxWindow::SetForeg
roundColour, wxColour());
} }
} }
else { impl_->validity_->SetLabel(label);
warning = true; impl_->validity_->SetForegroundColour(valid_date ? wxColour() : wxColour(
SetChildLabel(XRCID("ID_EXPIRATION_TIME"), _("Invalid date")); 255, 0, 0));
}
if (!cert.get_serial().empty()) { if (!cert.get_serial().empty()) {
SetChildLabel(XRCID("ID_SERIAL"), fz::to_wstring_from_utf8(cert.g et_serial())); impl_->serial_->SetLabel(LabelEscape(fz::to_wstring_from_utf8(cer t.get_serial())));
} }
else { else {
SetChildLabel(XRCID("ID_SERIAL"), _("None")); impl_->serial_->SetLabel(_("None"));
} }
SetChildLabel(XRCID("ID_PKALGO"), wxString::Format(_("%s with %d bits"), // @translator: Example: RSA with 2048 bits
fz::to_wstring_from_utf8(cert.get_pubkey_algorithm()), cert.get_pubkey_bits())); impl_->pubkey_algo_->SetLabel(wxString::Format(_("%s with %d bits"), fz::
SetChildLabel(XRCID("ID_SIGNALGO"), fz::to_wstring_from_utf8(cert.get_sig to_wstring_from_utf8(cert.get_pubkey_algorithm()), cert.get_pubkey_bits()));
nature_algorithm())); impl_->signature_algo_->SetLabel(fz::to_wstring_from_utf8(cert.get_signat
ure_algorithm()));
wxString const sha256 = fz::to_wstring_from_utf8(cert.get_fingerprint_sha auto recalc = [this](wxWindow* panel, wxSizer* sizer) {
256()); sizer->Fit(panel);
SetChildLabel(XRCID("ID_FINGERPRINT_SHA256"), sha256.Left(sha256.size() / wxSize min = sizer->CalcMin();
2 + 1) + L"\n" + sha256.Mid(sha256.size() / 2 + 1)); int const maxHeight = (line_height_ + layout().dlgUnits(1)) * 20;
SetChildLabel(XRCID("ID_FINGERPRINT_SHA1"), fz::to_wstring_from_utf8(cert if (min.y >= maxHeight) {
.get_fingerprint_sha1())); min.y = maxHeight;
min.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
}
ParseDN(XRCCTRL(*this, "ID_ISSUER_BOX", wxStaticBox), fz::to_wstring_from // Add extra safety margin to prevent squishing on OS X.
_utf8(cert.get_issuer()), m_pIssuerSizer); min.x += 2;
auto subjectPanel = XRCCTRL(*this, "ID_SUBJECT_PANEL", wxScrolledWindow); panel->SetMinSize(min);
subjectPanel->Freeze(); };
ParseDN(subjectPanel, fz::to_wstring_from_utf8(cert.get_subject()), m_pSu impl_->certPanel_->Freeze();
bjectSizer); ParseDN(impl_->certPanel_, fz::to_wstring_from_utf8(cert.get_subject()),
impl_->subjectSizer_);
auto const& altNames = cert.get_alt_subject_names(); auto const& altNames = cert.get_alt_subject_names();
if (!altNames.empty()) { if (!altNames.empty()) {
wxString str; wxString str;
for (auto const& altName : altNames) { for (auto const& altName : altNames) {
str += LabelEscape(fz::to_wstring_from_utf8(altName.name) ) + L"\n"; str += LabelEscape(fz::to_wstring_from_utf8(altName.name) ) + L"\n";
} }
str.RemoveLast(); str.RemoveLast();
m_pSubjectSizer->Add(new wxStaticText(subjectPanel, wxID_ANY, wxP impl_->subjectSizer_->Add(new wxStaticText(impl_->certPanel_, wxI
LURAL("Alternative name:", "Alternative names:", altNames.size()))); D_ANY, wxPLURAL("Alternative name:", "Alternative names:", altNames.size())));
m_pSubjectSizer->Add(new wxStaticText(subjectPanel, wxID_ANY, str impl_->subjectSizer_->Add(new wxStaticText(impl_->certPanel_, wxI
)); D_ANY, str));
} }
m_pSubjectSizer->Fit(subjectPanel);
wxSize min = m_pSubjectSizer->CalcMin(); if (cert.self_signed()) {
int const maxHeight = (line_height_ + ConvertDialogToPixels(wxPoint(0, 1) impl_->issuerSizer_->Clear(true);
).y) * 15; impl_->issuerSizer_->Add(new wxStaticText(impl_->certPanel_, -1,
if (min.y >= maxHeight) { _("Same as subject, certificate is self-signed")));
min.y = maxHeight; }
min.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); else {
ParseDN(impl_->certPanel_, fz::to_wstring_from_utf8(cert.get_issu
er()), impl_->issuerSizer_);
} }
// Add extra safety margin to prevent squishing on OS X. recalc(impl_->certPanel_, impl_->certSizer_);
min.x += 2; impl_->certPanel_->Thaw();
subjectPanel->SetMinSize(min);
subjectPanel->Thaw();
return warning; return valid_date;
} }
#include <wx/scrolwin.h> void CVerifyCertDialog::AddAlgorithm(wxWindow* parent, wxGridBagSizer* sizer, st
d::string const& name, bool insecure)
bool CVerifyCertDialog::DisplayAlgorithm(int controlId, std::string const& name,
bool insecure)
{ {
wxString wname = fz::to_wstring_from_utf8(name); wxString wname = fz::to_wstring_from_utf8(name);
if (insecure) { if (insecure) {
wname += L" - "; wname += L" - ";
wname += _("Insecure algorithm!"); wname += _("Insecure algorithm!");
auto wnd = FindWindow(controlId);
if (wnd) {
wnd->SetForegroundColour(wxColour(255, 0, 0));
}
} }
SetChildLabel(controlId, wname); auto * text = new wxStaticText(parent, -1, LabelEscape(wname.ToStdWstring
()));
layout().gbAdd(sizer, text);
return insecure; if (insecure) {
text->SetForegroundColour(wxColour(255, 0, 0));
}
} }
void CVerifyCertDialog::ShowVerificationDialog(CertStore & certStore, CCertifica teNotification& notification) void CVerifyCertDialog::ShowVerificationDialog(CertStore & certStore, CCertifica teNotification& notification)
{ {
CVerifyCertDialog dlg; CVerifyCertDialog dlg;
if (!dlg.CreateVerificationDialog(notification, false)) { if (!dlg.CreateVerificationDialog(notification, false)) {
return; return;
} }
int res = dlg.ShowModal(); int res = dlg.ShowModal();
if (res == wxID_OK) { if (res == wxID_OK) {
notification.trusted_ = true; notification.trusted_ = true;
if (!notification.info_.get_algorithm_warnings()) { if (!notification.info_.get_algorithm_warnings()) {
bool trustSANs = dlg.sanTrustAllowed_ && xrc_call(dlg, "I bool trustSANs = dlg.sanTrustAllowed_ && dlg.impl_->san_t
D_TRUST_SANS", &wxCheckBox::GetValue); rust_->GetValue();
bool permanent = !dlg.warning_ && xrc_call(dlg, "ID_ALWAY bool permanent = !dlg.warning_ && dlg.impl_->always_ && d
S", &wxCheckBox::GetValue); lg.impl_->always_->GetValue();
certStore.SetTrusted(notification.info_, permanent, trust SANs); certStore.SetTrusted(notification.info_, permanent, trust SANs);
} }
} }
else { else {
notification.trusted_ = false; notification.trusted_ = false;
} }
} }
void CVerifyCertDialog::DisplayCertificate(CCertificateNotification const& notif ication) void CVerifyCertDialog::DisplayCertificate(CCertificateNotification const& notif ication)
{ {
CVerifyCertDialog dlg; CVerifyCertDialog dlg;
if (dlg.CreateVerificationDialog(notification, true)) { if (dlg.CreateVerificationDialog(notification, true)) {
dlg.ShowModal(); dlg.ShowModal();
} }
} }
bool CVerifyCertDialog::CreateVerificationDialog(CCertificateNotification const& notification, bool displayOnly) bool CVerifyCertDialog::CreateVerificationDialog(CCertificateNotification const& notification, bool displayOnly)
{ {
fz::tls_session_info const& info = notification.info_; fz::tls_session_info const& info = notification.info_;
if (!Load(0, L"ID_VERIFYCERT", L"certificate.xrc")) { auto& lay = layout();
wxBell(); if (!Create(m_parent, -1, displayOnly ? _("Certificate details") : _("Unk
nown certificate"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxR
ESIZE_BORDER)) {
return false; return false;
} }
impl_ = std::make_unique<impl>();
if (displayOnly) { auto outer = lay.createMain(this, 2);
xrc_call(*this, "ID_DESC", &wxWindow::Hide); outer->AddGrowableCol(1);
xrc_call(*this, "ID_ALWAYS_DESC", &wxWindow::Hide); outer->AddGrowableRow(0);
xrc_call(*this, "ID_ALWAYS", &wxWindow::Hide);
xrc_call(*this, "ID_TRUST_SANS", &wxWindow::Hide); wxBitmap bmp = CThemeProvider::Get()->CreateBitmap(L"ART_LOCK", wxART_OTH
xrc_call(*this, "wxID_CANCEL", &wxWindow::Hide); ER, CThemeProvider::GetIconSize(iconSizeNormal));
SetTitle(L"Certificate details"); auto icon = new wxStaticBitmap(this, -1, bmp);
} outer->Add(icon);
else {
WrapText(this, XRCID("ID_DESC"), 420); auto main = lay.createFlex(1);
main->AddGrowableCol(0);
outer->Add(main, lay.grow);
if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2) if (!displayOnly) {
{ auto label1 = _("The server's certificate is unknown. Please care
XRCCTRL(*this, "ID_ALWAYS", wxCheckBox)->Hide(); fully examine the certificate to make sure the server can be trusted.");
WrapText(this, label1, 600);
main->Add(new wxStaticText(this, -1, label1));
auto label2 =_("Compare the displayed fingerprint with the certif
icate fingerprint you have received from your server adminstrator or server host
ing provider.");
WrapText(this, label2, 600);
main->Add(new wxStaticText(this, -1, label2));
}
impl_->certificates_ = info.get_certificates();
if (impl_->certificates_.size() > 1) {
auto row = lay.createFlex(2);
main->Add(row);
row->Add(new wxStaticText(this, -1, _("&Certificate in chain:")),
lay.valign);
auto choice = new wxChoice(this, -1);
row->Add(choice, lay.valign);
if (impl_->certificates_[0].self_signed()) {
choice->Append(L"0 (" + _("Self-signed server certificate
") + L")");
} }
} else {
choice->Append(L"0 (" + _("Server certificate") + L")");
}
for (unsigned int i = 1; i < impl_->certificates_.size(); ++i) {
if (impl_->certificates_[i].self_signed()) {
choice->Append(wxString::Format(L"%d", i) + L" ("
+ _("Root certificate") + L")");
}
else {
choice->Append(wxString::Format(L"%d", i) + L" ("
+ _("Intermediate certificate") + L")");
}
}
choice->SetSelection(0);
m_certificates = info.get_certificates(); choice->Bind(wxEVT_CHOICE, [this](auto const& ev) { OnCertificate
if (m_certificates.size() == 1) { Choice(ev); });
XRCCTRL(*this, "ID_CHAIN_DESC", wxStaticText)->Hide();
XRCCTRL(*this, "ID_CHAIN", wxChoice)->Hide();
} }
else {
wxChoice* pChoice = XRCCTRL(*this, "ID_CHAIN", wxChoice); {
for (unsigned int i = 0; i < m_certificates.size(); ++i) { main->AddGrowableRow(main->GetEffectiveRowsCount());
pChoice->Append(wxString::Format(L"%d", i)); auto row = lay.createGrid(1);
main->Add(row, lay.grow);
auto [box, boxsizer] = lay.createStatBox(row, _("Certificate"), 1
);
boxsizer->AddGrowableCol(0);
boxsizer->AddGrowableRow(0);
impl_->certPanel_ = new wxScrolledWindow(box, -1, wxDefaultPositi
on, wxDefaultSize, wxVSCROLL);
impl_->certPanel_->SetScrollRate(0, lay.dlgUnits(8));
boxsizer->Add(impl_->certPanel_, lay.grow);
impl_->certSizer_ = lay.createFlex(1);
impl_->certSizer_->SetVGap(lay.dlgUnits(2));
impl_->certPanel_->SetSizer(impl_->certSizer_);
{
auto heading = new wxStaticText(impl_->certPanel_, -1, _(
"Overview"));
heading->SetFont(heading->GetFont().Bold());
impl_->certSizer_->Add(heading);
auto inner = lay.createFlex(2);
inner->SetVGap(lay.dlgUnits(1));
impl_->certSizer_->Add(inner, 0, wxLEFT, lay.indent);
inner->Add(new wxStaticText(impl_->certPanel_, -1, _("Fin
gerprint (SHA-256):")));
impl_->fingerprint_sha256_ = new wxStaticText(impl_->cert
Panel_, -1, wxString());
inner->Add(impl_->fingerprint_sha256_);
inner->Add(new wxStaticText(impl_->certPanel_, -1, _("Fin
gerprint (SHA-1):")), lay.valign);
impl_->fingerprint_sha1_ = new wxStaticText(impl_->certPa
nel_, -1, wxString());
inner->Add(impl_->fingerprint_sha1_, lay.valign);
// @translator: Period as in a span of time with a start
and end date
inner->Add(new wxStaticText(impl_->certPanel_, -1, _("Val
idity period:")), lay.valign);
impl_->validity_ = new wxStaticText(impl_->certPanel_, -1
, wxString());
inner->Add(impl_->validity_, lay.valign);
}
impl_->certSizer_->AddSpacer(0);
{
auto heading = new wxStaticText(impl_->certPanel_, -1, _(
"Subject"));
heading->SetFont(heading->GetFont().Bold());
impl_->certSizer_->Add(heading);
auto inner = lay.createFlex(2);
impl_->certSizer_->Add(inner, 0, wxLEFT, lay.indent);
impl_->subjectSizer_ = lay.createFlex(2);
impl_->subjectSizer_->SetVGap(lay.dlgUnits(1));
impl_->certSizer_->Add(impl_->subjectSizer_, 0, wxLEFT, l
ay.indent);
}
impl_->certSizer_->AddSpacer(0);
{
auto heading = new wxStaticText(impl_->certPanel_, -1, _(
"Issuer"));
heading->SetFont(heading->GetFont().Bold());
impl_->certSizer_->Add(heading);
auto inner = lay.createFlex(2);
impl_->certSizer_->Add(inner, 0, wxLEFT, lay.indent);
impl_->issuerSizer_ = lay.createFlex(2);
impl_->issuerSizer_->SetVGap(lay.dlgUnits(1));
impl_->certSizer_->Add(impl_->issuerSizer_, 0, wxLEFT, la
y.indent);
} }
pChoice->SetSelection(0); impl_->certSizer_->AddSpacer(0);
{
auto heading = new wxStaticText(impl_->certPanel_, -1, _(
"Details"));
heading->SetFont(heading->GetFont().Bold());
impl_->certSizer_->Add(heading);
auto inner = lay.createFlex(2);
impl_->certSizer_->Add(inner, 0, wxLEFT, lay.indent);
inner->Add(new wxStaticText(impl_->certPanel_, -1, _("Ser
ial:")), lay.valign);
impl_->serial_ = new wxStaticText(impl_->certPanel_, -1,
wxString());
inner->Add(impl_->serial_, lay.valign);
inner->Add(new wxStaticText(impl_->certPanel_, -1, _("Pub
lic key algorithm:")), lay.valign);
impl_->pubkey_algo_ = new wxStaticText(impl_->certPanel_,
-1, wxString());
inner->Add(impl_->pubkey_algo_, lay.valign);
inner->Add(new wxStaticText(impl_->certPanel_, -1, _("Sig
nature algorithm:")), lay.valign);
impl_->signature_algo_ = new wxStaticText(impl_->certPane
l_, -1, wxString());
inner->Add(impl_->signature_algo_, lay.valign);
pChoice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHan dler(CVerifyCertDialog::OnCertificateChoice), 0, this); }
} }
{
auto [box, inner] = lay.createStatBox(main, _("Session details"),
1);
auto gb = lay.createGridBag(4);
inner->Add(gb);
lay.gbNewRow(gb);
lay.gbAdd(gb, new wxStaticText(box, -1, _("Host:")));
gb->SetVGap(lay.dlgUnits(1));
wxStaticText* host = new wxStaticText(box, -1, wxString());
if (info.mismatched_hostname()) {
host->SetLabel(wxString::Format(_("%s:%d - Hostname does
not match certificate"), LabelEscape(fz::to_wstring_from_utf8(info.get_host())),
info.get_port()));
host->SetForegroundColour(wxColour(255, 0, 0));
}
else {
host->SetLabel(wxString::Format(L"%s:%d", LabelEscape(fz:
:to_wstring_from_utf8(info.get_host())), info.get_port()));
}
lay.gbAdd(gb, host);
gb->SetItemSpan(1, wxGBSpan(1, 3));
lay.gbNewRow(gb);
lay.gbAdd(gb, new wxStaticText(box, -1, _("Protocol:")));
AddAlgorithm(box, gb, info.get_protocol(), (info.get_algorithm_wa
rnings() & fz::tls_session_info::tlsver) != 0);
if (info.mismatched_hostname()) { lay.gbAdd(gb, new wxStaticText(box, -1, _("Cipher:")));
xrc_call(*this, "ID_HOST", &wxWindow::SetForegroundColour, wxColo AddAlgorithm(box, gb, info.get_session_cipher(), (info.get_algori
ur(255, 0, 0)); thm_warnings() & fz::tls_session_info::cipher) != 0);
SetChildLabel(XRCID("ID_HOST"), wxString::Format(_("%s:%d - Hostn lay.gbNewRow(gb);
ame does not match certificate"), LabelEscape(fz::to_wstring_from_utf8(info.get_ lay.gbAdd(gb, new wxStaticText(box, -1, _("Key exchange:")));
host())), info.get_port())); AddAlgorithm(box, gb, info.get_key_exchange(), (info.get_algorith
m_warnings() & fz::tls_session_info::kex) != 0);
lay.gbAdd(gb, new wxStaticText(box, -1, _("Mac:")));
AddAlgorithm(box, gb, info.get_session_mac(), (info.get_algorithm
_warnings() & fz::tls_session_info::mac) != 0);
} }
else {
SetChildLabel(XRCID("ID_HOST"), wxString::Format(L"%s:%d", LabelE if (!displayOnly) {
scape(fz::to_wstring_from_utf8(info.get_host())), info.get_port())); main->Add(new wxStaticText(this, -1, _("Trust the server certific
ate and carry on connecting?")));
if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) != 2)
{
impl_->always_ = new wxCheckBox(this, -1, _("&Always trus
t this certificate in future sessions."));
main->Add(impl_->always_);
}
impl_->san_trust_ = new wxCheckBox(this, -1, _("&Trust this certi
ficate on the listed alternative hostnames."));
main->Add(impl_->san_trust_);
} }
line_height_ = XRCCTRL(*this, "ID_SUBJECT_DUMMY", wxStaticText)->GetSize( auto buttons = lay.createButtonSizer(this, main, false);
).y; auto ok = new wxButton(this, wxID_OK, _("OK"));
ok->SetDefault();
buttons->AddButton(ok);
if (!displayOnly) {
auto cancel = new wxButton(this, wxID_CANCEL, _("Cancel"));
buttons->AddButton(cancel);
}
buttons->Realize();
m_pSubjectSizer = XRCCTRL(*this, "ID_SUBJECT_DUMMY", wxStaticText)->GetCo line_height_ = impl_->validity_->GetSize().y;
ntainingSizer();
m_pSubjectSizer->Clear(true);
m_pIssuerSizer = XRCCTRL(*this, "ID_ISSUER_DUMMY", wxStaticText)->GetCont warning_ = false;
ainingSizer();
m_pIssuerSizer->Clear(true);
wxSize minSize(0, 0); wxSize minSize(0, 0);
for (unsigned int i = 0; i < m_certificates.size(); ++i) { for (unsigned int i = 0; i < impl_->certificates_.size(); ++i) {
DisplayCert(m_certificates[i]); if (!DisplayCert(impl_->certificates_[i])) {
warning_ = true;
}
Layout(); Layout();
GetSizer()->Fit(this); GetSizer()->Fit(this);
minSize.IncTo(GetSizer()->GetMinSize()); minSize.IncTo(GetSizer()->GetMinSize());
} }
GetSizer()->SetMinSize(minSize); GetSizer()->SetMinSize(minSize);
warning_ = DisplayCert(m_certificates[0]); DisplayCert(impl_->certificates_[0]);
DisplayAlgorithm(XRCID("ID_PROTOCOL"), info.get_protocol(), (info.get_alg
orithm_warnings() & fz::tls_session_info::tlsver) != 0);
DisplayAlgorithm(XRCID("ID_KEYEXCHANGE"), info.get_key_exchange(), (info.
get_algorithm_warnings() & fz::tls_session_info::kex) != 0);
DisplayAlgorithm(XRCID("ID_CIPHER"), info.get_session_cipher(), (info.get
_algorithm_warnings() & fz::tls_session_info::cipher) != 0);
DisplayAlgorithm(XRCID("ID_MAC"), info.get_session_mac(), (info.get_algor
ithm_warnings() & fz::tls_session_info::mac) != 0);
if (info.get_algorithm_warnings() != 0) { if (info.get_algorithm_warnings() != 0) {
warning_ = true; warning_ = true;
} }
if (warning_) { if (warning_) {
XRCCTRL(*this, "ID_IMAGE", wxStaticBitmap)->SetBitmap(wxArtProvid icon->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING));
er::GetBitmap(wxART_WARNING)); if (impl_->always_) {
XRCCTRL(*this, "ID_ALWAYS", wxCheckBox)->Enable(false); impl_->always_->Enable(false);
}
} }
bool const dnsname = fz::get_address_type(info.get_host()) == fz::address if (!displayOnly) {
_type::unknown; bool const dnsname = fz::get_address_type(info.get_host()) == fz:
sanTrustAllowed_ = !warning_ && dnsname && !info.mismatched_hostname(); :address_type::unknown;
XRCCTRL(*this, "ID_TRUST_SANS", wxCheckBox)->Enable(sanTrustAllowed_); sanTrustAllowed_ = !warning_ && dnsname && !info.mismatched_hostn
ame();
impl_->san_trust_->Enable(sanTrustAllowed_);
if (sanTrustAllowed_ && info.system_trust()) { if (sanTrustAllowed_ && info.system_trust()) {
xrc_call(*this, "ID_ALWAYS", &wxCheckBox::SetValue, true); if (impl_->always_) {
xrc_call(*this, "ID_TRUST_SANS", &wxCheckBox::SetValue, true); impl_->always_->SetValue(true);
}
impl_->san_trust_->SetValue(true);
}
} }
GetSizer()->Fit(this); GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints(this);
return true; return true;
} }
namespace { namespace {
std::vector<std::pair<std::wstring, std::wstring>> dn_split(std::wstring const& dn) std::vector<std::pair<std::wstring, std::wstring>> dn_split(std::wstring const& dn)
skipping to change at line 699 skipping to change at line 868
it = tokens.erase(it); it = tokens.erase(it);
} }
if (!value.empty()) { if (!value.empty()) {
pSizer->Add(new wxStaticText(parent, wxID_ANY, name)); pSizer->Add(new wxStaticText(parent, wxID_ANY, name));
pSizer->Add(new wxStaticText(parent, wxID_ANY, LabelEscape(value) )); pSizer->Add(new wxStaticText(parent, wxID_ANY, LabelEscape(value) ));
} }
} }
void CVerifyCertDialog::OnCertificateChoice(wxCommandEvent& event) void CVerifyCertDialog::OnCertificateChoice(wxCommandEvent const& event)
{ {
int sel = event.GetSelection(); int sel = event.GetSelection();
if (sel < 0 || static_cast<unsigned int>(sel) > m_certificates.size()) { if (sel < 0 || static_cast<unsigned int>(sel) > impl_->certificates_.size ()) {
return; return;
} }
DisplayCert(m_certificates[sel]); DisplayCert(impl_->certificates_[sel]);
Layout(); Layout();
GetSizer()->Fit(this); GetSizer()->Fit(this);
Refresh(); Refresh();
} }
void ConfirmInsecureConection(wxWindow* parent, CertStore & certStore, CInsecure ConnectionNotification & notification) void ConfirmInsecureConection(wxWindow* parent, CertStore & certStore, CInsecure ConnectionNotification & notification)
{ {
wxDialogEx dlg; wxDialogEx dlg;
skipping to change at line 780 skipping to change at line 949
auto buttons = lay.createButtonSizer(&dlg, main, true); auto buttons = lay.createButtonSizer(&dlg, main, true);
auto ok = new wxButton(&dlg, wxID_OK, _("&OK")); auto ok = new wxButton(&dlg, wxID_OK, _("&OK"));
if (!warning) { if (!warning) {
ok->SetFocus(); ok->SetFocus();
ok->SetDefault(); ok->SetDefault();
} }
buttons->AddButton(ok); buttons->AddButton(ok);
auto cancel = new wxButton(&dlg, wxID_CANCEL, _("&Cancel")); auto cancel = new wxButton(&dlg, wxID_CANCEL, _("Cancel"));
if (warning) { if (warning) {
cancel->SetFocus(); cancel->SetFocus();
cancel->SetDefault(); cancel->SetDefault();
} }
buttons->AddButton(cancel); buttons->AddButton(cancel);
auto onButton = [&dlg](wxEvent & evt) {dlg.EndModal(evt.GetId()); }; auto onButton = [&dlg](wxEvent & evt) {dlg.EndModal(evt.GetId()); };
ok->Bind(wxEVT_BUTTON, onButton); ok->Bind(wxEVT_BUTTON, onButton);
cancel->Bind(wxEVT_BUTTON, onButton); cancel->Bind(wxEVT_BUTTON, onButton);
 End of changes. 49 change blocks. 
153 lines changed or deleted 348 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)