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)
203 if (
id.length() == 0)
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);
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);
256 ipl->setTextFormat(TQt::PlainText);
257 urlLabel->setTextFormat(TQt::PlainText);
258 d->_serialNum->setTextFormat(TQt::PlainText);
259 d->_csl->setTextFormat(TQt::PlainText);
260 d->_validFrom->setTextFormat(TQt::PlainText);
261 d->_validUntil->setTextFormat(TQt::PlainText);
262 d->_digest->setTextFormat(TQt::PlainText);
269 d->_cert_ksvl.clear();
270 TQStringList errors = TQStringList::split(
':', errorNrs);
271 for(TQStringList::ConstIterator it = errors.begin();
272 it != errors.end(); ++it)
283 cspl = d->_validFrom->palette();
285 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
286 else cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
287 d->_validFrom->setPalette(cspl);
290 cspl = d->_validUntil->palette();
292 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
293 else cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
294 d->_validUntil->setPalette(cspl);
300 KSSLCertificate::KSSLValidationList ksvl;
301 if ((x == d->_cert) && !d->_cert_ksvl.isEmpty()) {
302 ksvl = d->_cert_ksvl;
306 ksvl = d->_cert->validateVerbose(KSSLCertificate::SSLServer);
308 ksvl = d->_cert->validateVerbose(KSSLCertificate::SSLServer, x);
311 ksvl << KSSLCertificate::Ok;
315 if (ksv == KSSLCertificate::SelfSigned) {
319 ksv = KSSLCertificate::Ok;
321 ksv = KSSLCertificate::Expired;
326 if (ksv == KSSLCertificate::Ok) {
327 cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
328 }
else if (ksv != KSSLCertificate::Irrelevant) {
329 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
331 d->_csl->setPalette(cspl);
334 for(KSSLCertificate::KSSLValidationList::ConstIterator it = ksvl.begin();
335 it != ksvl.end(); ++it) {
336 if (!errorStr.isEmpty())
337 errorStr.append(
'\n');
341 d->_csl->setText(errorStr);
342 d->_csl->setMinimumSize(d->_csl->sizeHint());
351 void KSSLInfoDlg::slotChain(
int x) {
353 displayCert(d->_cert);
355 TQPtrList<KSSLCertificate> cl = d->_cert->chain().getChain();
356 cl.setAutoDelete(
true);
357 for (
int i = 0; i < x-1; i++)
358 cl.remove((
unsigned int)0);
360 cl.remove((
unsigned int)0);
362 displayCert(&thisCert);
369 if (!certName.isEmpty()) {
370 result->
setValues(certName, mailCatcher);
377 : TQScrollView(parent, name, f)
380 setBackgroundMode(TQWidget::PaletteButton);
391 if (certName.isEmpty()) {
392 _frame =
new TQFrame(
this);
394 viewport()->setBackgroundMode(_frame->backgroundMode());
403 viewport()->setBackgroundMode(TQWidget::PaletteButton);
404 _frame =
new TQFrame(
this);
405 TQGridLayout *grid =
new TQGridLayout(_frame, 1, 2, KDialog::marginHint(), KDialog::spacingHint());
406 grid->setAutoAdd(
true);
408 if (!(tmp = cert.
getValue(
"O")).isEmpty()) {
409 label =
new TQLabel(i18n(
"Organization:"), _frame);
410 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
411 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
413 if (!(tmp = cert.
getValue(
"OU")).isEmpty()) {
414 label =
new TQLabel(i18n(
"Organizational unit:"), _frame);
415 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
416 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
418 if (!(tmp = cert.
getValue(
"L")).isEmpty()) {
419 label =
new TQLabel(i18n(
"Locality:"), _frame);
420 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
421 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
423 if (!(tmp = cert.
getValue(
"ST")).isEmpty()) {
424 label =
new TQLabel(i18n(
"Federal State",
"State:"), _frame);
425 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
426 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
428 if (!(tmp = cert.
getValue(
"C")).isEmpty()) {
429 label =
new TQLabel(i18n(
"Country:"), _frame);
430 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
431 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
433 if (!(tmp = cert.
getValue(
"CN")).isEmpty()) {
434 label =
new TQLabel(i18n(
"Common name:"), _frame);
435 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
436 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
438 if (!(tmp = cert.
getValue(
"Email")).isEmpty()) {
439 label =
new TQLabel(i18n(
"Email:"), _frame);
440 label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
442 KURLLabel *mail =
new KURLLabel(tmp, tmp, _frame);
443 connect(mail, TQT_SIGNAL(leftClickedURL(
const TQString &)), mailCatcher, TQT_SLOT(mailClicked(
const TQString &)));
445 label =
new TQLabel(tmp, _frame);
446 label->setTextFormat(TQt::PlainText);
449 if (label && viewport()) {
450 viewport()->setBackgroundMode(label->backgroundMode());
459 TQScrollView *KSSLInfoDlg::buildCertInfo(
const TQString &certName) {
463 void KSSLInfoDlg::urlClicked(
const TQString &url) {
464 kapp->invokeBrowser(url);
467 void KSSLInfoDlg::mailClicked(
const TQString &url) {
468 kapp->invokeMailer(url, TQString::null);
471 #include "ksslinfodlg.moc"