QList<QSslCipher> MumbleSSL::ciphersFromOpenSSLCipherString(QString cipherString) { QList<QSslCipher> chosenCiphers; SSL_CTX *ctx = NULL; SSL *ssl = NULL; const SSL_METHOD *meth = NULL; int i = 0; QByteArray csbuf = cipherString.toLatin1(); const char *ciphers = csbuf.constData(); meth = SSLv23_server_method(); if (meth == NULL) { qWarning("MumbleSSL: unable to get SSL method"); goto out; } // We use const_cast to be compatible with OpenSSL 0.9.8. ctx = SSL_CTX_new(const_cast<SSL_METHOD *>(meth)); if (ctx == NULL) { qWarning("MumbleSSL: unable to allocate SSL_CTX"); goto out; } if (!SSL_CTX_set_cipher_list(ctx, ciphers)) { qWarning("MumbleSSL: error parsing OpenSSL cipher string in ciphersFromOpenSSLCipherString"); goto out; } ssl = SSL_new(ctx); if (ssl == NULL) { qWarning("MumbleSSL: unable to create SSL object in ciphersFromOpenSSLCipherString"); goto out; } while (1) { const char *name = SSL_get_cipher_list(ssl, i); if (name == NULL) { break; } #if QT_VERSION >= 0x050300 QSslCipher c = QSslCipher(QString::fromLatin1(name)); if (!c.isNull()) { chosenCiphers << c; } #else foreach (const QSslCipher &c, QSslSocket::supportedCiphers()) { if (c.name() == QString::fromLatin1(name)) { chosenCiphers << c; } } #endif ++i; } out: SSL_CTX_free(ctx); SSL_free(ssl); return chosenCiphers; }
void QgsAuthSslImportDialog::socketEncrypted() { QgsDebugMsg( "socketEncrypted entered" ); if ( !mSocket ) return; // might have disconnected already appendString( tr( "Socket ENCRYPTED" ) ); appendString( QStringLiteral( "%1: %2" ).arg( tr( "Protocol" ), QgsAuthCertUtils::getSslProtocolName( mSocket->protocol() ) ) ); QSslCipher ciph = mSocket->sessionCipher(); QString cipher = QStringLiteral( "%1: %2, %3 (%4/%5)" ) .arg( tr( "Session cipher" ), ciph.authenticationMethod(), ciph.name() ) .arg( ciph.usedBits() ).arg( ciph.supportedBits() ); appendString( cipher ); wdgtSslConfig->setEnabled( true ); QString hostport( QStringLiteral( "%1:%2" ).arg( mSocket->peerName() ).arg( mSocket->peerPort() ) ); wdgtSslConfig->setSslCertificate( mSocket->peerCertificate(), hostport.trimmed() ); if ( !mSslErrors.isEmpty() ) { wdgtSslConfig->appendSslIgnoreErrors( mSslErrors ); mSslErrors.clear(); } // checkCanSave(); // must come after last state change, or gets reverted leServer->setStyleSheet( QgsAuthGuiUtils::greenTextStyleSheet() ); destroySocket(); }
void SslClient::socketEncrypted() { QSslCipher ciph = ssl_->sessionCipher(); QString cipher = QString("%1, %2 (%3/%4)").arg(ciph.authenticationMethod()) .arg(ciph.name()).arg(ciph.usedBits()).arg(ciph.supportedBits()); CDebug() << "SSL cipher " << cipher; }
QDebug operator<<(QDebug debug, const QSslCipher &cipher) { debug << "QSslCipher(name=" << qPrintable(cipher.name()) << ", bits=" << cipher.usedBits() << ", proto=" << qPrintable(cipher.protocolString()) << ")"; return debug; }
QDebug operator<<(QDebug debug, const QSslCipher &cipher) { QDebugStateSaver saver(debug); debug.resetFormat().nospace().noquote(); debug << "QSslCipher(name=" << cipher.name() << ", bits=" << cipher.usedBits() << ", proto=" << cipher.protocolString() << ')'; return debug; }
void Server::connectionAccepted() { qDebug() << "SERVER: Now connected"; qDebug() << "SERVER: Connection is encrypted:" << clientConnection -> isEncrypted(); qDebug() << "SERVER: Socket Descriptor:" << clientConnection -> socketDescriptor(); QSslCipher ciph = clientConnection->sessionCipher(); QString cipher = QString("%1, %2 (%3/%4)").arg(ciph.authenticationMethod()).arg(ciph.name()).arg(ciph.usedBits()).arg(ciph.supportedBits()); qDebug() << "SERVER: Cipher:" << cipher; connected=1; emit readyToSendData(); }
QString dumpCipher(const QSslCipher &cipher) { QString s = "\n"; s += "Authentication: " + cipher.authenticationMethod() + "\n"; s += "Encryption: " + cipher.encryptionMethod() + "\n"; s += "Key Exchange: " + cipher.keyExchangeMethod() + "\n"; s += "Cipher Name: " + cipher.name() + "\n"; s += "Protocol: " + cipher.protocolString() + "\n"; s += "Supported Bits: " + QString(cipher.supportedBits()) + "\n"; s += "Used Bits: " + QString(cipher.usedBits()) + "\n"; return s; }
QString Server :: getSSLCypher() { QString cipher(""); if(connected) //I know it's not pretty but it looks a lot better than a segfault :P if(clientConnection!=0) if(clientConnection -> isOpen()) { QSslCipher ciph = clientConnection->sessionCipher(); cipher = QString("%1, %2 (%3/%4)").arg(ciph.authenticationMethod()).arg(ciph.name()).arg(ciph.usedBits()).arg(ciph.supportedBits()); } return cipher; }
void SslClient::socketEncrypted() { form->sessionOutput->clear(); form->sessionInput->setFocus(); QPalette palette; palette.setColor(QPalette::Base, QColor(255, 255, 192)); form->hostNameEdit->setPalette(palette); const QSslCipher cipher = socket->sessionCipher(); const QString cipherInfo = QString("%1, %2 (%3/%4)").arg(cipher.authenticationMethod()) .arg(cipher.name()).arg(cipher.usedBits()) .arg(cipher.supportedBits());; form->cipherLabel->setText(cipherInfo); padLock->show(); }
SslInfoDlg::SslInfoDlg(const QSslSocket *socket, QWidget *parent) : QDialog(parent), _socket(socket) { ui.setupUi(this); QSslCipher cipher = socket->sessionCipher(); ui.hostname->setText(socket->peerName()); ui.address->setText(socket->peerAddress().toString()); ui.encryption->setText(cipher.name()); ui.protocol->setText(cipher.protocolString()); connect(ui.certificateChain, SIGNAL(currentIndexChanged(int)), SLOT(setCurrentCert(int))); foreach(const QSslCertificate &cert, socket->peerCertificateChain()) { ui.certificateChain->addItem(subjectInfo(cert, QSslCertificate::CommonName)); } }
void SslClient::socketEncrypted() { if (!socket) return; // might have disconnected already form->sessionOutput->clear(); form->sessionInput->setFocus(); QPalette palette; palette.setColor(QPalette::Base, QColor(255, 255, 192)); form->hostNameEdit->setPalette(palette); QSslCipher ciph = socket->sessionCipher(); QString cipher = QString("%1, %2 (%3/%4)").arg(ciph.authenticationMethod()) .arg(ciph.name()).arg(ciph.usedBits()).arg(ciph.supportedBits());; form->cipherLabel->setText(cipher); if (!padLock) { padLock = new QToolButton; padLock->setIcon(QIcon(":/encrypted.png")); #ifndef QT_NO_CURSOR padLock->setCursor(Qt::ArrowCursor); #endif padLock->setToolTip(tr("Display encryption details.")); int extent = form->hostNameEdit->height() - 2; padLock->resize(extent, extent); padLock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); QHBoxLayout *layout = new QHBoxLayout(form->hostNameEdit); layout->setMargin(form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth)); layout->setSpacing(0); layout->addStretch(); layout->addWidget(padLock); form->hostNameEdit->setLayout(layout); connect(padLock, SIGNAL(clicked()), this, SLOT(displayCertificateInfo())); } else { padLock->show(); } }
//! [3] void SslClient::socketEncrypted() { if (!m_socket) return; // Might have disconnected already // We started a new connection, so clear the response from previous connections m_response.clear(); emit responseChanged(); // Retrieve the information about the used cipher and update the property const QSslCipher cipher = m_socket->sessionCipher(); m_cipher = QString("%1, %2 (%3/%4)").arg(cipher.authenticationMethod()) .arg(cipher.name()) .arg(cipher.usedBits()) .arg(cipher.supportedBits()); emit cipherChanged(); // Tell the CertificateInfoControl about the certificate chain of this connection emit certificateChainChanged(m_socket->peerCertificateChain()); }
void SslButton::updateAccountInfo(Account *account) { if (!account || account->state() != Account::Connected) { setVisible(false); return; } else { setVisible(true); } if (account->url().scheme() == QLatin1String("https")) { setIcon(QIcon(QPixmap(":/mirall/resources/lock-https.png"))); QSslCipher cipher = account->sslConfiguration().sessionCipher(); setToolTip(tr("This connection is encrypted using %1 bit %2.\n").arg(cipher.usedBits()).arg(cipher.name())); QMenu *menu = new QMenu(this); QList<QSslCertificate> chain = account->sslConfiguration().peerCertificateChain(); menu->addAction(tr("Certificate information:"))->setEnabled(false); QList<QSslCertificate> tmpChain; foreach(QSslCertificate cert, chain) { tmpChain << cert; if (QSslSocket::systemCaCertificates().contains(cert)) break; }