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, TQ_SIGNAL(clicked()), TQ_SLOT(launchConfig()));
111 buttonLayout->addWidget( button );
114 button =
new KPushButton(KStdGuiItem::close(),
this);
115 connect(button, TQ_SIGNAL(clicked()), TQ_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."));
145 d->info->setText(i18n(
"Some of this document is secured with SSL, but the main part is not."));
150 d->pixmap->setPixmap(BarIcon(
"encrypted"));
151 d->info->setText(i18n(
"Current connection is secured with SSL."));
154 d->pixmap->setPixmap(BarIcon(
"decrypted"));
155 d->info->setText(i18n(
"Current connection is not secured with SSL."));
178 const TQString& ip,
const TQString& url,
179 const TQString& cipher,
const TQString& cipherdesc,
180 const TQString& sslversion,
int usedbits,
int bits,
186 TQGridLayout *layout =
new TQGridLayout(4, 2, KDialog::spacingHint());
188 layout->addWidget(
new TQLabel(i18n(
"Chain:"),
this), 0, 0);
189 d->_chain =
new KComboBox(
this);
190 layout->addMultiCellWidget(d->_chain, 1, 1, 0, 1);
191 connect(d->_chain, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotChain(
int)));
196 d->_chain->setEnabled(
true);
197 d->_chain->insertItem(i18n(
"0 - Site Certificate"));
200 cl.setAutoDelete(
true);
205 if (
id.length() == 0)
207 if (
id.length() == 0)
209 d->_chain->insertItem(TQString::number(++cnt)+
" - "+
id);
211 d->_chain->setCurrentItem(0);
212 }
else d->_chain->setEnabled(
false);
214 layout->addWidget(
new TQLabel(i18n(
"Peer certificate:"),
this), 2, 0);
216 layout->addWidget(
new TQLabel(i18n(
"Issuer:"),
this), 2, 1);
217 layout->addWidget(d->_issuer =
static_cast<KSSLCertBox*
>(buildCertInfo(cert->
getIssuer())), 3, 1);
218 d->m_layout->addMultiCell(layout, 1, 1, 0, 2);
220 layout =
new TQGridLayout(11, 2, KDialog::spacingHint());
221 layout->setColStretch(1, 1);
222 TQLabel *ipl =
new TQLabel(i18n(
"IP address:"),
this);
223 layout->addWidget(ipl, 0, 0);
227 layout->addWidget(ipl =
new TQLabel(ip,
this), 0, 1);
231 layout->addWidget(
new TQLabel(i18n(
"URL:"),
this), 1, 0);
232 KSqueezedTextLabel *urlLabel =
new KSqueezedTextLabel(url,
this);
233 layout->addWidget(urlLabel, 1, 1);
234 layout->addWidget(
new TQLabel(i18n(
"Certificate state:"),
this), 2, 0);
236 layout->addWidget(d->_csl =
new TQLabel(
"",
this), 2, 1);
240 layout->addWidget(
new TQLabel(i18n(
"Valid from:"),
this), 3, 0);
241 layout->addWidget(d->_validFrom =
new TQLabel(
"",
this), 3, 1);
242 layout->addWidget(
new TQLabel(i18n(
"Valid until:"),
this), 4, 0);
243 layout->addWidget(d->_validUntil =
new TQLabel(
"",
this), 4, 1);
245 layout->addWidget(
new TQLabel(i18n(
"Serial number:"),
this), 5, 0);
246 layout->addWidget(d->_serialNum =
new TQLabel(
"",
this), 5, 1);
247 layout->addWidget(
new TQLabel(i18n(
"MD5 digest:"),
this), 6, 0);
248 layout->addWidget(d->_digest =
new TQLabel(
"",
this), 6, 1);
250 layout->addWidget(
new TQLabel(i18n(
"Cipher in use:"),
this), 7, 0);
251 layout->addWidget(
new TQLabel(cipher,
this), 7, 1);
252 layout->addWidget(
new TQLabel(i18n(
"Details:"),
this), 8, 0);
253 layout->addWidget(
new TQLabel(cipherdesc.simplifyWhiteSpace(),
this), 8, 1);
254 layout->addWidget(
new TQLabel(i18n(
"SSL version:"),
this), 9, 0);
255 layout->addWidget(
new TQLabel(sslversion,
this), 9, 1);
256 layout->addWidget(
new TQLabel(i18n(
"Cipher strength:"),
this), 10, 0);
257 layout->addWidget(
new TQLabel(i18n(
"%1 bits used of a %2 bit cipher").arg(usedbits).arg(bits),
this), 10, 1);
258 d->m_layout->addMultiCell(layout, 2, 2, 0, 2);
260 ipl->setTextFormat(TQt::PlainText);
261 urlLabel->setTextFormat(TQt::PlainText);
262 d->_serialNum->setTextFormat(TQt::PlainText);
263 d->_csl->setTextFormat(TQt::PlainText);
264 d->_validFrom->setTextFormat(TQt::PlainText);
265 d->_validUntil->setTextFormat(TQt::PlainText);
266 d->_digest->setTextFormat(TQt::PlainText);
273 d->_cert_ksvl.clear();
274 TQStringList errors = TQStringList::split(
':', errorNrs);
275 for(TQStringList::ConstIterator it = errors.begin();
276 it != errors.end(); ++it)
287 cspl = d->_validFrom->palette();
289 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
290 else cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
291 d->_validFrom->setPalette(cspl);
294 cspl = d->_validUntil->palette();
296 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
297 else cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
298 d->_validUntil->setPalette(cspl);
304 KSSLCertificate::KSSLValidationList ksvl;
305 if ((x == d->_cert) && !d->_cert_ksvl.isEmpty()) {
306 ksvl = d->_cert_ksvl;
310 ksvl = d->_cert->validateVerbose(KSSLCertificate::SSLServer);
312 ksvl = d->_cert->validateVerbose(KSSLCertificate::SSLServer, x);
315 ksvl << KSSLCertificate::Ok;
319 if (ksv == KSSLCertificate::SelfSigned) {
320 if (x->
getQDTNotAfter() > TQDateTime::currentDateTime(TQt::UTC) &&
323 ksv = KSSLCertificate::Ok;
325 ksv = KSSLCertificate::Expired;
330 if (ksv == KSSLCertificate::Ok) {
331 cspl.setColor(TQColorGroup::Foreground, TQColor(42,153,59));
332 }
else if (ksv != KSSLCertificate::Irrelevant) {
333 cspl.setColor(TQColorGroup::Foreground, TQColor(196,33,21));
335 d->_csl->setPalette(cspl);
338 for(KSSLCertificate::KSSLValidationList::ConstIterator it = ksvl.begin();
339 it != ksvl.end(); ++it) {
340 if (!errorStr.isEmpty())
341 errorStr.append(
'\n');
345 d->_csl->setText(errorStr);
346 d->_csl->setMinimumSize(d->_csl->sizeHint());
355 void KSSLInfoDlg::slotChain(
int x) {
357 displayCert(d->_cert);
359 TQPtrList<KSSLCertificate> cl = d->_cert->chain().getChain();
360 cl.setAutoDelete(
true);
361 for (
int i = 0; i < x-1; i++)
362 cl.remove((
unsigned int)0);
364 cl.remove((
unsigned int)0);
366 displayCert(&thisCert);
373 if (!certName.isEmpty()) {
374 result->
setValues(certName, mailCatcher);
381 : TQScrollView(parent, name, f)
384 setBackgroundMode(TQWidget::PaletteButton);
395 if (certName.isEmpty()) {
396 _frame =
new TQFrame(
this);
398 viewport()->setBackgroundMode(_frame->backgroundMode());
407 viewport()->setBackgroundMode(TQWidget::PaletteButton);
408 _frame =
new TQFrame(
this);
409 TQGridLayout *grid =
new TQGridLayout(_frame, 1, 2, KDialog::marginHint(), KDialog::spacingHint());
410 grid->setAutoAdd(
true);
412 if (!(tmp = cert.
getValue(
"O")).isEmpty()) {
413 label =
new TQLabel(i18n(
"Organization:"), _frame);
414 label->setAlignment(TQt::AlignLeft | TQt::AlignTop);
415 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
417 if (!(tmp = cert.
getValue(
"OU")).isEmpty()) {
418 label =
new TQLabel(i18n(
"Organizational unit:"), _frame);
419 label->setAlignment(TQt::AlignLeft | TQt::AlignTop);
420 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
422 if (!(tmp = cert.
getValue(
"L")).isEmpty()) {
423 label =
new TQLabel(i18n(
"Locality:"), _frame);
424 label->setAlignment(TQt::AlignLeft | TQt::AlignTop);
425 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
427 if (!(tmp = cert.
getValue(
"ST")).isEmpty()) {
428 label =
new TQLabel(i18n(
"Federal State",
"State:"), _frame);
429 label->setAlignment(TQt::AlignLeft | TQt::AlignTop);
430 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
432 if (!(tmp = cert.
getValue(
"C")).isEmpty()) {
433 label =
new TQLabel(i18n(
"Country:"), _frame);
434 label->setAlignment(TQt::AlignLeft | TQt::AlignTop);
435 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
437 if (!(tmp = cert.
getValue(
"CN")).isEmpty()) {
438 label =
new TQLabel(i18n(
"Common name:"), _frame);
439 label->setAlignment(TQt::AlignLeft | TQt::AlignTop);
440 (
new TQLabel(tmp, _frame))->setTextFormat(TQt::PlainText);
442 if (!(tmp = cert.
getValue(
"Email")).isEmpty()) {
443 label =
new TQLabel(i18n(
"Email:"), _frame);
444 label->setAlignment(TQt::AlignLeft | TQt::AlignTop);
446 KURLLabel *mail =
new KURLLabel(tmp, tmp, _frame);
447 connect(mail, TQ_SIGNAL(leftClickedURL(
const TQString &)), mailCatcher, TQ_SLOT(mailClicked(
const TQString &)));
449 label =
new TQLabel(tmp, _frame);
450 label->setTextFormat(TQt::PlainText);
453 if (label && viewport()) {
454 viewport()->setBackgroundMode(label->backgroundMode());
463 TQScrollView *KSSLInfoDlg::buildCertInfo(
const TQString &certName) {
467 void KSSLInfoDlg::urlClicked(
const TQString &url) {
468 kapp->invokeBrowser(url);
471 void KSSLInfoDlg::mailClicked(
const TQString &url) {
472 kapp->invokeMailer(url, TQString::null);
475 #include "ksslinfodlg.moc"