22 #include "ksslinfodlg.h"
27 #include <kpushbutton.h>
30 #include <tqscrollview.h>
33 #include <tdeapplication.h>
34 #include <tdeglobal.h>
35 #include <tdelocale.h>
37 #include <kiconloader.h>
38 #include <tdeglobalsettings.h>
39 #include <ksqueezedtextlabel.h>
40 #include <kurllabel.h>
41 #include <kstdguiitem.h>
44 #include <kcombobox.h>
45 #include "ksslcertificate.h"
46 #include "ksslcertchain.h"
47 #include "ksslsigners.h"
50 class KSSLInfoDlg::KSSLInfoDlgPrivate {
54 TQGridLayout *m_layout;
57 KSSLCertificate::KSSLValidationList _cert_ksvl;
76 : KDialog(parent, name, modal, (WFlags)TQt::WDestructiveClose), d(new KSSLInfoDlgPrivate) {
77 TQVBoxLayout *topLayout =
new TQVBoxLayout(
this, KDialog::marginHint(), KDialog::spacingHint());
78 d->m_secCon = secureConnection;
79 d->m_layout =
new TQGridLayout(topLayout, 3, 3, KDialog::spacingHint());
80 d->m_layout->setColStretch(1, 1);
81 d->m_layout->setColStretch(2, 1);
83 d->pixmap =
new TQLabel(
this);
84 d->m_layout->addWidget(d->pixmap, 0, 0);
86 d->info =
new TQLabel(
this);
87 d->m_layout->addWidget(d->info, 0, 1);
91 d->pixmap->setPixmap(BarIcon(
"encrypted"));
92 d->info->setText(i18n(
"Current connection is secured with SSL."));
94 d->pixmap->setPixmap(BarIcon(
"decrypted"));
95 d->info->setText(i18n(
"Current connection is not secured with SSL."));
98 d->pixmap->setPixmap(BarIcon(
"decrypted"));
99 d->info->setText(i18n(
"SSL support is not available in this build of TDE."));
101 d->m_layout->addRowSpacing( 0, 50 );
103 TQHBoxLayout *buttonLayout =
new TQHBoxLayout(topLayout, KDialog::spacingHint());
104 buttonLayout->addStretch( 1 );
109 button =
new KPushButton(KGuiItem(i18n(
"C&ryptography Configuration..."),
"configure"),
this);
110 connect(button, TQT_SIGNAL(clicked()), TQT_SLOT(launchConfig()));
111 buttonLayout->addWidget( button );
114 button =
new KPushButton(KStdGuiItem::close(),
this);
115 connect(button, TQT_SIGNAL(clicked()), TQT_SLOT(close()));
116 buttonLayout->addWidget( button );
120 setCaption(i18n(
"TDE SSL Information"));
121 d->inQuestion =
false;
129 void KSSLInfoDlg::launchConfig() {
131 p <<
"tdecmshell" <<
"crypto";
132 p.start(TDEProcess::DontCare);
137 d->inQuestion = isIt;
140 d->pixmap->setPixmap(BarIcon(
"halfencrypted"));
142 d->info->setText(i18n(
"The main part of this document is secured with SSL, but some parts are not."));
144 d->info->setText(i18n(
"Some of this document is secured with SSL, but the main part is not."));
148 d->pixmap->setPixmap(BarIcon(
"encrypted"));
149 d->info->setText(i18n(
"Current connection is secured with SSL."));
151 d->pixmap->setPixmap(BarIcon(
"decrypted"));
152 d->info->setText(i18n(
"Current connection is not secured with SSL."));
174 const TQString& ip,
const TQString& url,
175 const TQString& cipher,
const TQString& cipherdesc,
176 const TQString& sslversion,
int usedbits,
int bits,
182 TQGridLayout *layout =
new TQGridLayout(4, 2, KDialog::spacingHint());
184 layout->addWidget(
new TQLabel(i18n(
"Chain:"),
this), 0, 0);
185 d->_chain =
new KComboBox(
this);
186 layout->addMultiCellWidget(d->_chain, 1, 1, 0, 1);
187 connect(d->_chain, TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(slotChain(
int)));
192 d->_chain->setEnabled(
true);
193 d->_chain->insertItem(i18n(
"0 - Site Certificate"));
196 cl.setAutoDelete(
true);
201 if (
id.length() == 0)
202 id = map.getValue(
"O");
203 if (
id.length() == 0)
204 id = map.getValue(
"OU");
205 d->_chain->insertItem(TQString::number(++cnt)+
" - "+
id);
207 d->_chain->setCurrentItem(0);
208 }
else d->_chain->setEnabled(
false);
210 layout->addWidget(
new TQLabel(i18n(
"Peer certificate:"),
this), 2, 0);
211 layout->addWidget(d->_subject = static_cast<KSSLCertBox*>(buildCertInfo(cert->
getSubject())), 3, 0);
212 layout->addWidget(
new TQLabel(i18n(
"Issuer:"),
this), 2, 1);
213 layout->addWidget(d->_issuer = static_cast<KSSLCertBox*>(buildCertInfo(cert->
getIssuer())), 3, 1);
214 d->m_layout->addMultiCell(layout, 1, 1, 0, 2);
216 layout =
new TQGridLayout(11, 2, KDialog::spacingHint());
217 layout->setColStretch(1, 1);
218 TQLabel *ipl =
new TQLabel(i18n(
"IP address:"),
this);
219 layout->addWidget(ipl, 0, 0);
223 layout->addWidget(ipl =
new TQLabel(ip,
this), 0, 1);
227 layout->addWidget(
new TQLabel(i18n(
"URL:"),
this), 1, 0);
228 KSqueezedTextLabel *urlLabel =
new KSqueezedTextLabel(url,
this);
229 layout->addWidget(urlLabel, 1, 1);
230 layout->addWidget(
new TQLabel(i18n(
"Certificate state:"),
this), 2, 0);
232 layout->addWidget(d->_csl =
new TQLabel(
"",
this), 2, 1);
236 layout->addWidget(
new TQLabel(i18n(
"Valid from:"),
this), 3, 0);
237 layout->addWidget(d->_validFrom =
new TQLabel(
"",
this), 3, 1);
238 layout->addWidget(
new TQLabel(i18n(
"Valid until:"),
this), 4, 0);
239 layout->addWidget(d->_validUntil =
new TQLabel(
"",
this), 4, 1);
241 layout->addWidget(
new TQLabel(i18n(
"Serial number:"),
this), 5, 0);
242 layout->addWidget(d->_serialNum =
new TQLabel(
"",
this), 5, 1);
243 layout->addWidget(
new TQLabel(i18n(
"MD5 digest:"),
this), 6, 0);
244 layout->addWidget(d->_digest =
new TQLabel(
"",
this), 6, 1);
246 layout->addWidget(
new TQLabel(i18n(
"Cipher in use:"),
this), 7, 0);
247 layout->addWidget(
new TQLabel(cipher,
this), 7, 1);
248 layout->addWidget(
new TQLabel(i18n(
"Details:"),
this), 8, 0);
249 layout->addWidget(
new TQLabel(cipherdesc.simplifyWhiteSpace(),
this), 8, 1);
250 layout->addWidget(
new TQLabel(i18n(
"SSL version:"),
this), 9, 0);
251 layout->addWidget(
new TQLabel(sslversion,
this), 9, 1);
252 layout->addWidget(
new TQLabel(i18n(
"Cipher strength:"),
this), 10, 0);
253 layout->addWidget(
new TQLabel(i18n(
"%1 bits used of a %2 bit cipher").arg(usedbits).arg(bits),
this), 10, 1);
254 d->m_layout->addMultiCell(layout, 2, 2, 0, 2);
261 d->_cert_ksvl.clear();
262 TQStringList errors = TQStringList::split(
':', errorNrs);
263 for(TQStringList::ConstIterator it = errors.begin();
264 it != errors.end(); ++it)
275 cspl = d->_validFrom->palette();
277 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
278 else cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
279 d->_validFrom->setPalette(cspl);
282 cspl = d->_validUntil->palette();
284 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
285 else cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
286 d->_validUntil->setPalette(cspl);
292 KSSLCertificate::KSSLValidationList ksvl;
293 if ((x == d->_cert) && !d->_cert_ksvl.isEmpty()) {
294 ksvl = d->_cert_ksvl;
298 ksvl = d->_cert->validateVerbose(KSSLCertificate::SSLServer);
300 ksvl = d->_cert->validateVerbose(KSSLCertificate::SSLServer, x);
303 ksvl << KSSLCertificate::Ok;
307 if (ksv == KSSLCertificate::SelfSigned) {
311 ksv = KSSLCertificate::Ok;
313 ksv = KSSLCertificate::Expired;
318 if (ksv == KSSLCertificate::Ok) {
319 cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
320 }
else if (ksv != KSSLCertificate::Irrelevant) {
321 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
323 d->_csl->setPalette(cspl);
326 for(KSSLCertificate::KSSLValidationList::ConstIterator it = ksvl.begin();
327 it != ksvl.end(); ++it) {
328 if (!errorStr.isEmpty())
329 errorStr.append(
'\n');
333 d->_csl->setText(errorStr);
334 d->_csl->setMinimumSize(d->_csl->sizeHint());
343 void KSSLInfoDlg::slotChain(
int x) {
345 displayCert(d->_cert);
347 TQPtrList<KSSLCertificate> cl = d->_cert->chain().getChain();
348 cl.setAutoDelete(
true);
349 for (
int i = 0; i < x-1; i++)
350 cl.remove((
unsigned int)0);
352 cl.remove((
unsigned int)0);
354 displayCert(&thisCert);
361 if (!certName.isEmpty()) {
362 result->
setValues(certName, mailCatcher);
369 : TQScrollView(parent, name, f)
372 setBackgroundMode(TQWidget::PaletteButton);
383 if (certName.isEmpty()) {
384 _frame =
new TQFrame(
this);
386 viewport()->setBackgroundMode(_frame->backgroundMode());
395 viewport()->setBackgroundMode(TQWidget::PaletteButton);
396 _frame =
new TQFrame(
this);
397 TQGridLayout *grid =
new TQGridLayout(_frame, 1, 2, KDialog::marginHint(), KDialog::spacingHint());
398 grid->setAutoAdd(
true);
400 if (!(tmp = cert.
getValue(
"O")).isEmpty()) {
401 label =
new TQLabel(i18n(
"Organization:"), _frame);
402 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
403 new TQLabel(tmp, _frame);
405 if (!(tmp = cert.
getValue(
"OU")).isEmpty()) {
406 label =
new TQLabel(i18n(
"Organizational unit:"), _frame);
407 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
408 new TQLabel(tmp, _frame);
410 if (!(tmp = cert.
getValue(
"L")).isEmpty()) {
411 label =
new TQLabel(i18n(
"Locality:"), _frame);
412 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
413 new TQLabel(tmp, _frame);
415 if (!(tmp = cert.
getValue(
"ST")).isEmpty()) {
416 label =
new TQLabel(i18n(
"Federal State",
"State:"), _frame);
417 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
418 new TQLabel(tmp, _frame);
420 if (!(tmp = cert.
getValue(
"C")).isEmpty()) {
421 label =
new TQLabel(i18n(
"Country:"), _frame);
422 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
423 new TQLabel(tmp, _frame);
425 if (!(tmp = cert.
getValue(
"CN")).isEmpty()) {
426 label =
new TQLabel(i18n(
"Common name:"), _frame);
427 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
428 new TQLabel(tmp, _frame);
430 if (!(tmp = cert.
getValue(
"Email")).isEmpty()) {
431 label =
new TQLabel(i18n(
"Email:"), _frame);
432 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
434 KURLLabel *mail =
new KURLLabel(tmp, tmp, _frame);
435 connect(mail, TQT_SIGNAL(leftClickedURL(
const TQString &)), mailCatcher, TQT_SLOT(mailClicked(
const TQString &)));
437 label =
new TQLabel(tmp, _frame);
440 if (label && viewport()) {
441 viewport()->setBackgroundMode(label->backgroundMode());
450 TQScrollView *KSSLInfoDlg::buildCertInfo(
const TQString &certName) {
454 void KSSLInfoDlg::urlClicked(
const TQString &url) {
455 kapp->invokeBrowser(url);
458 void KSSLInfoDlg::mailClicked(
const TQString &url) {
459 kapp->invokeMailer(url, TQString::null);
462 #include "ksslinfodlg.moc"