本文整理汇总了C++中QSslSocket::setSocketDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C++ QSslSocket::setSocketDescriptor方法的具体用法?C++ QSslSocket::setSocketDescriptor怎么用?C++ QSslSocket::setSocketDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSslSocket
的用法示例。
在下文中一共展示了QSslSocket::setSocketDescriptor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: incomingConnection
void HTTPSManager::incomingConnection(qintptr socketDescriptor) {
QSslSocket* sslSocket = new QSslSocket(this);
sslSocket->setLocalCertificate(_certificate);
sslSocket->setPrivateKey(_privateKey);
if (sslSocket->setSocketDescriptor(socketDescriptor)) {
new HTTPSConnection(sslSocket, this);
} else {
delete sslSocket;
}
}
示例2: incomingConnection
void QSslServer::incomingConnection(qintptr socket)
{
QSslSocket *pSslSocket = new QSslSocket();
if (Q_LIKELY(pSslSocket)) {
pSslSocket->setSslConfiguration(m_sslConfiguration);
if (Q_LIKELY(pSslSocket->setSocketDescriptor(socket)))
{
typedef void (QSslSocket::* sslErrorsSignal)(const QList<QSslError> &);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 2)
connect(pSslSocket, &QSslSocket::peerVerifyError, this, &QSslServer::peerVerifyError);
connect(pSslSocket, &QSslSocket::encrypted, this, &QSslServer::newEncryptedConnection);
#else
connect(pSslSocket,SIGNAL(peerVerifyError(QSslError)), this, SIGNAL(peerVerifyError(QSslError)));
connect(pSslSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SIGNAL(sslErrors(QList<QSslError>)));
connect(pSslSocket, SIGNAL(encrypted()), this, SIGNAL(newEncryptedConnection()));
#endif
addPendingConnection(pSslSocket);
pSslSocket->startServerEncryption();
}
else
{
delete pSslSocket;
}
}
}
示例3: incomingConnection
void QTlsServer::incomingConnection(int socketDescriptor)
{
QSslSocket* serverSocket = new QSslSocket;
QObject::connect(serverSocket, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(displayTlsErrors(const QList<QSslError>&)));
if (serverSocket->setSocketDescriptor(socketDescriptor))
{
QFile file("server-key.pem");
if (!file.open(QIODevice::ReadOnly))
{
std::cout << "can't open key" << "server-key.pem";
return;
}
QSslKey key(&file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, QByteArray("qtwebsocket-server-key"));
file.close();
serverSocket->setPrivateKey(key);
if (!serverSocket->addCaCertificates("ca.pem"))
{
std::cout << "open certificate ca error" << "ca.pem";
return;
}
serverSocket->setLocalCertificate("server-crt.pem");
serverSocket->setPeerVerifyMode(QSslSocket::VerifyNone);
//serverSocket->ignoreSslErrors();
QObject::connect(serverSocket, SIGNAL(encrypted()), this, SLOT(tlsSocketEncrypted()));
serverSocket->startServerEncryption();
}
else
{
serverSocket->deleteLater();
}
}
示例4: QSslSocket
QTcpSocket *Nuria::Internal::TcpServer::handleToSocket (qintptr handle) {
if (!this->m_ssl) {
QTcpSocket *socket = new QTcpSocket;
socket->setSocketDescriptor (handle);
return socket;
}
// SSL
#ifndef NURIA_NO_SSL_HTTP
QSslSocket *socket = new QSslSocket (this);
// Certificate and private key
socket->setPrivateKey (this->m_key);
socket->setLocalCertificate (this->m_cert);
// Set handle
if (!socket->setSocketDescriptor (handle)) {
delete socket;
return nullptr;
}
//
socket->startServerEncryption ();
return socket;
#else
return nullptr;
#endif
}
示例5: incomingConnection
void InVpnSslServer::incomingConnection(int socketDescriptor) {
QSslSocket *serverSocket = new QSslSocket(this);
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
ready(serverSocket);
} else {
delete serverSocket;
}
}
示例6: slot_newIncommingConnection
void SshServer::slot_newIncommingConnection( int socketDescriptor )
{
QSslSocket* sslSocket = new QSslSocket();
// before the handshake, we need to adjust some security parameters for SSL
QSsl::SslProtocol sslProtocol;
if( "SSL-v3" == _sshServerSettings._version )
sslProtocol = QSsl::SslV3;
else if( "TLS-v1" == _sshServerSettings._version )
sslProtocol = QSsl::TlsV1;
else
{
logError( this, "no valid SSL version to use" );
delete sslSocket;
return;
}
QSsl::EncodingFormat ecodingFormat = ("PER"==_sshServerSettings._format) ? QSsl::Pem : QSsl::Der;
QSsl::KeyAlgorithm algorithm = ("RSA"==_sshServerSettings._cipher) ? QSsl::Rsa : QSsl::Dsa;
QByteArray password;
// setting the SSL version to use
sslSocket->setProtocol( sslProtocol );
// ensure that the peer's certificate will be verified
sslSocket->setPeerVerifyMode( QSslSocket::VerifyPeer );
// ensure that the peer's cerficiate and its issuer's certificate will be verified
sslSocket->setPeerVerifyDepth( 2 );
// setting server's certificate
sslSocket->setLocalCertificate( _sshServerSettings._certificate, ecodingFormat );
// setting server's private key
sslSocket->setPrivateKey( _sshServerSettings._privateKey, algorithm, ecodingFormat, password );
// setting the CA ceritificate
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath( _sshServerSettings._certificate, ecodingFormat );
sslSocket->setDefaultCaCertificates( caCertificates );
// setup some traps for the socket events
connect( sslSocket, SIGNAL(disconnected()), sslSocket, SLOT(deleteLater()) );
connect( sslSocket, SIGNAL(encrypted()), SLOT(slot_SuccessfulConnected()) );
connect( sslSocket, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(slot_UnSuccessfulConnected(const QList<QSslError>&)) );
connect( sslSocket, SIGNAL(readyRead()), this, SLOT(slot_IncommingData()) );
// start the handshake
bool result = sslSocket->setSocketDescriptor( socketDescriptor );
if( false == result )
{
logError( this, QString("failed to set socket descriptor: %1").arg(sslSocket->errorString()) );
delete sslSocket;
return;
}
sslSocket->startServerEncryption();
}
示例7: incomingConnection
void SslServer::incomingConnection(qintptr handle)
{
QSslSocket *socket = new QSslSocket(this);
socket->setSocketDescriptor(handle);
socket->setLocalCertificate(_cert);
socket->setPrivateKey(_key);
addPendingConnection(socket);
}
示例8: incomingConnection
//! [1]
void SslServer::incomingConnection(qintptr socketDescriptor)
{
QSslSocket *serverSocket = new QSslSocket;
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
connect(serverSocket, SIGNAL(encrypted()), this, SLOT(ready()));
serverSocket->startServerEncryption();
} else {
delete serverSocket;
}
}
示例9: operator
QAbstractSocket* SslSocketCreation::operator()() const {
QSslSocket* socket = new QSslSocket();
socket->setSocketDescriptor(socketDescriptor);
socket->setLocalCertificate(certificate);
socket->setPrivateKey(privateKey);
socket->startServerEncryption();
return socket;
}
示例10: incomingConnection
//! [1]
void SslServer::incomingConnection(qintptr socketDescriptor)
{
QSslSocket *serverSocket = new QSslSocket;
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
addPendingConnection(serverSocket);
connect(serverSocket, &QSslSocket::encrypted, this, &SslServer::ready);
serverSocket->startServerEncryption();
} else {
delete serverSocket;
}
}
示例11: incomingConnection
// Intercept new socket connection and enable SSL
void SslServer::incomingConnection(int socketDescriptor)
{
QSslSocket *serverSocket = new QSslSocket();
if (serverSocket->setSocketDescriptor(socketDescriptor))
{
addPendingConnection (serverSocket);
}
else
{
delete serverSocket;
}
}
示例12: QSslSocket
QAbstractSocket * HttpsSocket::createSocket(qintptr socketDescriptor)
{
QSslSocket * socket = new QSslSocket();
socket->setSocketDescriptor(socketDescriptor);
socket->setLocalCertificate(m_certificate);
socket->setPrivateKey(m_privateKey);
socket->startServerEncryption();
return socket;
}
示例13: incomingConnection
QIODevice* QxtSslConnectionManager::incomingConnection(int socketDescriptor)
#endif
{
QSslSocket* socket = new QSslSocket(this);
if(socket->setSocketDescriptor(socketDescriptor)) {
socket->setLocalCertificate(qxt_d().localCertificate());
socket->setPrivateKey(qxt_d().privateKey());
if(qxt_d().autoEncrypt()) socket->startServerEncryption();
return socket;
} else {
delete socket;
return 0;
}
}
示例14: incomingConnection
void SslServer::incomingConnection(int socketDescriptor)
{
QSslSocket *serverSocket = new QSslSocket(this);
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
if (isCertValid()) {
serverSocket->setLocalCertificate(_cert);
serverSocket->setPrivateKey(_key);
serverSocket->addCaCertificates(_ca);
}
_pendingConnections << serverSocket;
emit newConnection();
}
else {
delete serverSocket;
}
}
示例15: incomingConnection
/**
* Called when a new connection is available. The newConnection()
* signal is emitted when the connection is added to the pending
* connections queue
*
* @brief SslServer::incomingConnection
* @param socketDescriptor
*
* Ref: http://doc.qt.io/qt-5/qtcpserver.html#incomingConnection
*/
void SslServer::incomingConnection(qintptr socketDescriptor)
{
QSslSocket *mSslSocket = new QSslSocket(this);
if(mSslSocket->setSocketDescriptor(socketDescriptor))
{
mSslSocket->setProtocol(mProtocol);
mSslSocket->setLocalCertificate(mLocalCertificate);
mSslSocket->setPrivateKey(mPrivateKey);
this->addPendingConnection(mSslSocket);
}
else
{
delete mSslSocket;
qDebug() << "QSslSocket pointer deleted";
}
}