当前位置: 首页>>代码示例>>C++>>正文


C++ QSslConfiguration::setCaCertificates方法代码示例

本文整理汇总了C++中QSslConfiguration::setCaCertificates方法的典型用法代码示例。如果您正苦于以下问题:C++ QSslConfiguration::setCaCertificates方法的具体用法?C++ QSslConfiguration::setCaCertificates怎么用?C++ QSslConfiguration::setCaCertificates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSslConfiguration的用法示例。


在下文中一共展示了QSslConfiguration::setCaCertificates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadSettings

void NetworkAccessManager::loadSettings()
{
    QSettings settings;
    settings.beginGroup(QLatin1String("proxy"));
    QNetworkProxy proxy;
    if (settings.value(QLatin1String("enabled"), false).toBool()) {
        if (settings.value(QLatin1String("type"), 0).toInt() == 0)
            proxy.setType(QNetworkProxy::Socks5Proxy);
        else
            proxy.setType(QNetworkProxy::HttpProxy);
        proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
        proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
        proxy.setUser(settings.value(QLatin1String("userName")).toString());
        proxy.setPassword(settings.value(QLatin1String("password")).toString());
    }
    setProxy(proxy);
    settings.endGroup();

#ifndef QT_NO_OPENSSL
    QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
    QList<QSslCertificate> ca_list = sslCfg.caCertificates();
    QList<QSslCertificate> ca_new = QSslCertificate::fromData(settings.value(QLatin1String("CaCertificates")).toByteArray());
    ca_list += ca_new;

    sslCfg.setCaCertificates(ca_list);
    QSslConfiguration::setDefaultConfiguration(sslCfg);
#endif
}
开发者ID:ariya,项目名称:arora,代码行数:28,代码来源:networkaccessmanager.cpp

示例2: nam

BluecherryApp::BluecherryApp()
    : nam(new QNetworkAccessManager(this)), liveView(new LiveViewManager(this)),
      globalRate(new TransferRateCalculator(this)), m_updateChecker(0),
      m_livePaused(false), m_inPauseQuery(false),
      m_screensaverInhibited(false), m_screensaveValue(0)
{
    Q_ASSERT(!bcApp);
    bcApp = this;

    m_serverRepository = new DVRServerRepository(this);

    connect(qApp, SIGNAL(aboutToQuit()), SLOT(aboutToQuit()));

    appIcon.addFile(QLatin1String(":/icons/icon16.png"));
    appIcon.addFile(QLatin1String(":/icons/icon32.png"));
    appIcon.addFile(QLatin1String(":/icons/icon64.png"));
    appIcon.addFile(QLatin1String(":/icons/bluecherry-client.png"));
    qApp->setWindowIcon(appIcon);

    connect(nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));

    /* Don't use the system CAs to verify certificates */
    QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
    sslConfig.setCaCertificates(QList<QSslCertificate>());
#if QT_VERSION >= 0x040800
    /* SNI breaks connections (before sslError, even) when the hostname does
     * not match the server. */
    sslConfig.setSslOption(QSsl::SslOptionDisableServerNameIndication, true);
#endif
    QSslConfiguration::setDefaultConfiguration(sslConfig);

    loadServers();
    if (shouldAddLocalServer())
        addLocalServer();
    autoConnectServers();

    sendSettingsChanged();

    m_updateChecker = new UpdateChecker(nam, this);
    connect(m_updateChecker, SIGNAL(newVersionAvailable(Version)), this, SLOT(newVersionAvailable(Version)));
    QSettings settings;

    if (!settings.value(QLatin1String("ui/disableUpdateNotifications"), false).toBool())
    {
        startUpdateChecker();
    }

    m_mediaDownloadManager = new MediaDownloadManager(this);
    m_mediaDownloadManager->setCookieJar(nam->cookieJar());

    m_eventDownloadManager = new EventDownloadManager(this);
    connect(m_serverRepository, SIGNAL(serverRemoved(DVRServer*)), m_eventDownloadManager, SLOT(serverRemoved(DVRServer*)));

    registerVideoPlayerFactory();

    connect(qApp, SIGNAL(commitDataRequest(QSessionManager&)), this, SLOT(commitDataRequest(QSessionManager&)));
    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveSettings()));
}
开发者ID:xjz,项目名称:bluecherry-client,代码行数:58,代码来源:BluecherryApp.cpp

示例3: addHighFidelityRootCAToSSLConfig

void OAuthWebViewHandler::addHighFidelityRootCAToSSLConfig() {
    QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
    
    // add the High Fidelity root CA to the list of trusted CA certificates
    QByteArray highFidelityCACertificate(HIGH_FIDELITY_CA, sizeof(HIGH_FIDELITY_CA));
    sslConfig.setCaCertificates(sslConfig.caCertificates() + QSslCertificate::fromData(highFidelityCACertificate));
    
    // set the modified configuration
    QSslConfiguration::setDefaultConfiguration(sslConfig);
}
开发者ID:Adrianl3d,项目名称:hifi,代码行数:10,代码来源:OAuthWebViewHandler.cpp

示例4: cert

LoginTester::LoginTester(QString username,
                         QString password,
                         int maxcount,
                         QWidget *parent) :
    QDialog(parent, Qt::FramelessWindowHint),
    ui(new Ui::LoginTester)
{
    ui->setupUi(this);
    ui->button->hide();

    // Initialisieren der Variablen
    tryCounter = 0;
    this->maxTries      = maxcount;
    this->username      = username;
    this->password      = password;

    // Initialisieren des NetworkManagers und der Slots
    manager = new QNetworkAccessManager(qApp);

    QFile cert(":/certs/l2p");
    cert.open(QFile::ReadOnly);
    QList<QSslCertificate> newCertificates = QSslCertificate::fromData(cert.readAll(),QSsl::Der);
    cert.close();
    QSslCertificate newCertificate = newCertificates.first();

    QFile cert2(":/certs/utn");
    cert2.open(QFile::ReadOnly);
    QList<QSslCertificate> newCertificates2 = QSslCertificate::fromData(cert2.readAll(),QSsl::Der);
    cert2.close();
    QSslCertificate newCertificate2 = newCertificates2.first();

    QFile cert3(":/certs/ssl");
    cert3.open(QFile::ReadOnly);
    QList<QSslCertificate> newCertificates3 = QSslCertificate::fromData(cert3.readAll(),QSsl::Der);
    cert3.close();
    QSslCertificate newCertificate3 = newCertificates3.first();


    QSslConfiguration newSslConfiguration = QSslConfiguration::defaultConfiguration();
    newCertificates = newSslConfiguration.caCertificates();
    newCertificates.append(newCertificate);
    newCertificates.append(newCertificate2);
    newCertificates.append(newCertificate3);
    newSslConfiguration.setCaCertificates(newCertificates);
    QSslConfiguration::setDefaultConfiguration(newSslConfiguration);

    QSslConfiguration newSslConfiguration2 = QSslConfiguration::defaultConfiguration();
    newCertificates2 = newSslConfiguration2.caCertificates();
    foreach (QSslCertificate c, newCertificates2)
    {
        QStringList list = QStringList(c.subjectInfo(QSslCertificate::CommonName));
        for(QStringList::iterator i = list.begin(); i != list.end(); i++){
            qDebug(i->toLatin1());
        }
    }
开发者ID:eMPee584,项目名称:Sync-my-L2P,代码行数:55,代码来源:logintester.cpp

示例5: sslErrors

void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
{
    BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();

    QSettings settings;
    QList<QSslCertificate> ca_merge = QSslCertificate::fromData(settings.value(QLatin1String("CaCertificates")).toByteArray());

    QList<QSslCertificate> ca_new;
    QStringList errorStrings;
    for (int i = 0; i < error.count(); ++i) {
        if (ca_merge.contains(error.at(i).certificate()))
            continue;
        errorStrings += error.at(i).errorString();
        if (!error.at(i).certificate().isNull()) {
            ca_new.append(error.at(i).certificate());
        }
    }
    if (errorStrings.isEmpty()) {
        reply->ignoreSslErrors();
        return;
    }

    QString errors = errorStrings.join(QLatin1String("\n"));
    int ret = QMessageBox::warning(mainWindow, QCoreApplication::applicationName(),
                           tr("SSL Errors:\n\n%1\n\n%2\n\n"
                              "Do you want to ignore these errors?").arg(reply->url().toString()).arg(errors),
                           QMessageBox::Yes | QMessageBox::No,
                           QMessageBox::No);

    if (ret == QMessageBox::Yes) {
        if (ca_new.count() > 0) {
            ret = QMessageBox::question(mainWindow, QCoreApplication::applicationName(),
                tr("Do you want to accept all these certificates?"),
                QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
            if (ret == QMessageBox::Yes) {
                ca_merge += ca_new;

                QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
                QList<QSslCertificate> ca_list = sslCfg.caCertificates();
                ca_list += ca_new;
                sslCfg.setCaCertificates(ca_list);
                QSslConfiguration::setDefaultConfiguration(sslCfg);
                reply->setSslConfiguration(sslCfg);

                QByteArray pems;
                for (int i = 0; i < ca_merge.count(); ++i)
                    pems += ca_merge.at(i).toPem() + '\n';
                settings.setValue(QLatin1String("CaCertificates"), pems);
            }
        }
        reply->ignoreSslErrors();
    }
}
开发者ID:ariya,项目名称:arora,代码行数:53,代码来源:networkaccessmanager.cpp

示例6: loadSettings

void NetworkAccessManager::loadSettings()
{
    QSettings settings;
    settings.beginGroup(QLatin1String("proxy"));
    QNetworkProxy proxy;
    if (settings.value(QLatin1String("enabled"), false).toBool()) {
        int proxyType = settings.value(QLatin1String("type"), 0).toInt();
        if (proxyType == 0)
            proxy = QNetworkProxy::Socks5Proxy;
        else if (proxyType == 1)
            proxy = QNetworkProxy::HttpProxy;
        else { // 2
            proxy.setType(QNetworkProxy::HttpCachingProxy);
#if QT_VERSION >= 0x040500
            proxy.setCapabilities(QNetworkProxy::CachingCapability | QNetworkProxy::HostNameLookupCapability);
#endif
        }
        proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
        proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
        proxy.setUser(settings.value(QLatin1String("userName")).toString());
        proxy.setPassword(settings.value(QLatin1String("password")).toString());
    }
#if QT_VERSION >= 0x040500
    NetworkProxyFactory *proxyFactory = new NetworkProxyFactory;
    if (proxy.type() == QNetworkProxy::HttpCachingProxy) {
      proxyFactory->setHttpProxy(proxy);
      proxyFactory->setGlobalProxy(QNetworkProxy::DefaultProxy);
    } else {
      proxyFactory->setHttpProxy(QNetworkProxy::DefaultProxy);
      proxyFactory->setGlobalProxy(proxy);
    }
    setProxyFactory(proxyFactory);
#else
    setProxy(proxy);
#endif
    settings.endGroup();

#ifndef QT_NO_OPENSSL
    QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
    QList<QSslCertificate> ca_list = sslCfg.caCertificates();
    QList<QSslCertificate> ca_new = QSslCertificate::fromData(settings.value(QLatin1String("CaCertificates")).toByteArray());
    ca_list += ca_new;

    sslCfg.setCaCertificates(ca_list);
    QSslConfiguration::setDefaultConfiguration(sslCfg);
#endif

    settings.beginGroup(QLatin1String("network"));
    QStringList acceptList = settings.value(QLatin1String("acceptLanguages"),
            AcceptLanguageDialog::defaultAcceptList()).toStringList();
    acceptLanguage = AcceptLanguageDialog::httpString(acceptList);
    settings.endGroup();
}
开发者ID:porphyr,项目名称:arora,代码行数:53,代码来源:networkaccessmanager.cpp

示例7: qSslProtocolFromString

bool KIO::Integration::sslConfigFromMetaData(const KIO::MetaData& metadata, QSslConfiguration& sslconfig)
{
    bool success = false;

    if (metadata.contains(QL1S("ssl_in_use"))) {
        const QSsl::SslProtocol sslProto = qSslProtocolFromString(metadata.value(QL1S("ssl_protocol_version")));
        QList<QSslCipher> cipherList;
        cipherList << QSslCipher(metadata.value(QL1S("ssl_cipher_name")), sslProto);
        sslconfig.setCaCertificates(QSslCertificate::fromData(metadata.value(QL1S("ssl_peer_chain")).toUtf8()));
        sslconfig.setCiphers(cipherList);
        sslconfig.setProtocol(sslProto);
        success = sslconfig.isNull();
    }

    return success;
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例8: getJsonDocument

QJsonDocument Picasa::getJsonDocument(QUrl url){
    QNetworkRequest request(url);
    request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
    // TODO: install ssl certificate maybe solved in qt 5.1
    QSslConfiguration sslConfig = request.sslConfiguration();
    QList<QSslCertificate> certs = QSslCertificate::fromPath(":/plugins/picasa-download/picasacrt");
    sslConfig.setCaCertificates(certs);
    request.setSslConfiguration(sslConfig);
    QNetworkAccessManager manager;
    QNetworkReply *reply = manager.get(request);
    QEventLoop loop;
    QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();
    QByteArray rep = reply->readAll();
    return QJsonDocument().fromJson(rep);
}
开发者ID:FalseCAM,项目名称:reihenaufnahme,代码行数:16,代码来源:picasa.cpp

示例9: getOrCreateSslConfig

QSslConfiguration Account::getOrCreateSslConfig()
{
    if (!_sslConfiguration.isNull()) {
        // Will be set by CheckServerJob::finished()
        // We need to use a central shared config to get SSL session tickets
        return _sslConfiguration;
    }

    // if setting the client certificate fails, you will probably get an error similar to this:
    //  "An internal error number 1060 happened. SSL handshake failed, client certificate was requested: SSL error: sslv3 alert handshake failure"
    QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
    QSslCertificate sslClientCertificate;
    
    ConfigFile cfgFile;
    if(!cfgFile.certificatePath().isEmpty() && !cfgFile.certificatePasswd().isEmpty()) {
        resultP12ToPem certif = p12ToPem(cfgFile.certificatePath().toStdString(), cfgFile.certificatePasswd().toStdString());
        QString s = QString::fromStdString(certif.Certificate);
        QByteArray ba = s.toLocal8Bit();
        this->setCertificate(ba, QString::fromStdString(certif.PrivateKey));
    }
    if((!_pemCertificate.isEmpty())&&(!_pemPrivateKey.isEmpty())) {
        // Read certificates
        QList<QSslCertificate> sslCertificateList = QSslCertificate::fromData(_pemCertificate, QSsl::Pem);
        if(sslCertificateList.length() != 0) {
            sslClientCertificate = sslCertificateList.takeAt(0);
        }
        // Read key from file
        QSslKey privateKey(_pemPrivateKey.toLocal8Bit(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey , "");

        // SSL configuration
        sslConfig.setCaCertificates(QSslSocket::systemCaCertificates());
        sslConfig.setLocalCertificate(sslClientCertificate);
        sslConfig.setPrivateKey(privateKey);
        qDebug() << "Added SSL client certificate to the query";
    }

#if QT_VERSION > QT_VERSION_CHECK(5, 2, 0)
    // Try hard to re-use session for different requests
    sslConfig.setSslOption(QSsl::SslOptionDisableSessionTickets, false);
    sslConfig.setSslOption(QSsl::SslOptionDisableSessionSharing, false);
    sslConfig.setSslOption(QSsl::SslOptionDisableSessionPersistence, false);
#endif

    return sslConfig;
}
开发者ID:ronynksoft,项目名称:client,代码行数:45,代码来源:account.cpp

示例10: getPixmap

QPixmap AlbumWidget::getPixmap(QString url){
    QByteArray bytes;
    QNetworkRequest request(url);
    request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
    QSslConfiguration sslConfig = request.sslConfiguration();
    QList<QSslCertificate> certs = QSslCertificate::fromPath(":/plugins/picasa-download/picasacrt");
    sslConfig.setCaCertificates(certs);
    request.setSslConfiguration(sslConfig);
    QNetworkAccessManager manager;
    QNetworkReply *reply = manager.get(request);
    QEventLoop loop;
    QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();
    bytes = reply->readAll();
    QImage img;
    img.loadFromData(bytes);
    return QPixmap::fromImage(img.scaledToHeight(32));
}
开发者ID:FalseCAM,项目名称:reihenaufnahme,代码行数:18,代码来源:albumwidget.cpp

示例11: setSslConfiguration

bool KDSoapUnitTestHelpers::setSslConfiguration()
{
    initResource();

    // To make SSL work, we need to tell Qt about our local certificate

    // Both ways work:
#if 0
    QSslConfiguration defaultConfig = QSslConfiguration::defaultConfiguration();
    QFile certFile(QString::fromLatin1(":/certs/cacert.pem"));
    if (!certFile.open(QIODevice::ReadOnly)) {
        qDebug() << "Could not open cacert.pem";
        return false;
    }
    QSslCertificate cert(&certFile);
    if (!cert.isValid())
        return false;
    defaultConfig.setCaCertificates(QList<QSslCertificate>() << cert);
    QSslConfiguration::setDefaultConfiguration(defaultConfig);
#endif

    QFile certFile(QString::fromLatin1(":/certs/cacert.pem"));
    if (!certFile.open(QIODevice::ReadOnly)) {
        qDebug() << "Could not open cacert.pem";
        return false;
    }
    QSslCertificate cert(&certFile);
    const QDateTime currentTime = QDateTime::currentDateTime();
    if (cert.effectiveDate() > currentTime
            || cert.expiryDate() < currentTime) {
        qDebug() << "Certificate" << certFile.fileName() << "is not valid";
        qDebug() << "It is valid from" << cert.effectiveDate() << "to" << cert.expiryDate();
        return false;
    }
    QSslSocket::addDefaultCaCertificate(cert);

    return true;
}
开发者ID:nbeudez,项目名称:KDSoap,代码行数:38,代码来源:httpserver_p.cpp

示例12: QDialog

ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle* platformStyle, QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::ReceiveCoinsDialog)
    , model(0)
    , platformStyle(platformStyle)
#if defined(HAVE_WEBENGINE_VIEW) || defined(HAVE_WEBKIT)
    , buyView(NULL)
#endif
    , buyReceiveAddress(NULL)
    , currentAccount(NULL)
{
    ui->setupUi(this);

    ui->accountRequestPaymentButton->setCursor(Qt::PointingHandCursor);
    ui->accountBuyGuldenButton->setCursor(Qt::PointingHandCursor);
    ui->accountBuyButton->setCursor(Qt::PointingHandCursor);
    ui->accountSaveQRButton->setCursor(Qt::PointingHandCursor);
    ui->accountCopyToClipboardButton->setCursor(Qt::PointingHandCursor);
    ui->cancelButton->setCursor(Qt::PointingHandCursor);
    ui->closeButton->setCursor(Qt::PointingHandCursor);
    ui->generateRequestButton->setCursor(Qt::PointingHandCursor);
    ui->generateAnotherRequestButton->setCursor(Qt::PointingHandCursor);

    connect(ui->accountCopyToClipboardButton, SIGNAL(clicked()), this, SLOT(copyAddressToClipboard()));
    connect(ui->accountBuyGuldenButton, SIGNAL(clicked()), this, SLOT(showBuyGuldenDialog()));
    connect(ui->accountBuyButton, SIGNAL(clicked()), this, SLOT(buyGulden()));
    connect(ui->accountSaveQRButton, SIGNAL(clicked()), this, SLOT(saveQRAsImage()));
    connect(ui->accountRequestPaymentButton, SIGNAL(clicked()), this, SLOT(gotoRequestPaymentPage()));
    connect(ui->generateAnotherRequestButton, SIGNAL(clicked()), this, SLOT(gotoRequestPaymentPage()));
    connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancelRequestPayment()));
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(cancelRequestPayment()));

    connect(ui->generateRequestButton, SIGNAL(clicked()), this, SLOT(generateRequest()));

    updateAddress("");

    gotoReceievePage();

#ifdef HAVE_WEBENGINE_VIEW
    buyView = new WebEngineView(this);
    buyView->setAttribute(Qt::WA_TranslucentBackground);
    ui->buyGuldenPageLayout->addWidget(buyView);
    buyView->show();

    ui->loadingAnimationLabel->setObjectName("buy_page_error_text");
#elif defined(HAVE_WEBKIT)
    buyView = new WebView(this);
    buyView->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
    buyView->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    buyView->settings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true);
    buyView->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
    buyView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, false);
    buyView->settings()->setAttribute(QWebSettings::SpatialNavigationEnabled, true);
    buyView->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
    buyView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);

#ifdef MAC_OSX
    QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
    QList<QSslCertificate> ca_list = sslCfg.caCertificates();
    QList<QSslCertificate> ca_new = QSslCertificate::fromData("CaCertificates");
    ca_list += ca_new;

    sslCfg.setCaCertificates(ca_list);
    sslCfg.setProtocol(QSsl::AnyProtocol);
    QSslConfiguration::setDefaultConfiguration(sslCfg);

    connect(buyView->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(sslErrorHandler(QNetworkReply*, const QList<QSslError>&)));
#endif

    ui->buyGuldenPageLayout->addWidget(buyView);
    buyView->show();

    ui->loadingAnimationLabel->setObjectName("buy_page_error_text");
#else
    ui->accountBuyGuldenButton->setVisible(false);
#endif
}
开发者ID:strataghyst,项目名称:gulden-official,代码行数:77,代码来源:receivecoinsdialog.cpp

示例13: resetNetworkRequest

void resetNetworkRequest(QNetworkRequest * request){
    QSslConfiguration config = request->sslConfiguration();
    config.setCaCertificates(QSslCertificate::fromPath("../TwitterQT2/trusted rootCAs/*/*",QSsl::Pem,QRegExp::WildcardUnix));
    request->setSslConfiguration(config);
}
开发者ID:Ranlvor,项目名称:crosstweeter,代码行数:5,代码来源:crossTweeter.cpp

示例14: sslErrorHandler


//.........这里部分代码省略.........
            int loadStoredCert = aegis_certman_load_cert(ownDomain, crtKeyId, &storedCert);

            if (loadStoredCert == 0 && storedCert != NULL)
            {
                QLOG_INFO() << "Network Load Cert: " << loadStoredCert;

                // convert internal X509 structure to DER
                int len;
                unsigned char *buf;

                buf = NULL;

                len = i2d_X509(storedCert, &buf);

                if (len > 0) {
                    // create Qt Certificate from buffer
                    QByteArray buffer(reinterpret_cast<const char*>(buf), len);
                    QSslCertificate sslCert(buffer, QSsl::Der);

                    // create list and append cert
                    QList<QSslCertificate> sslCerts;
                    sslCerts.append(sslCert);

                    // put ssl into ssl error for ignored errors
                    QSslError sslError(QSslError::SelfSignedCertificate, sslCerts.at(0));
                    QList<QSslError> expectedSslErrors;
                    expectedSslErrors.append(sslError);

                    // add certificate to socket and current configuration
                    QSslSocket::addDefaultCaCertificates(sslCerts);
                    QList<QSslCipher> ciphers = rep->sslConfiguration().ciphers();
                    QSslConfiguration sslConfig;
                    sslConfig.setCiphers(ciphers);
                    sslConfig.setCaCertificates(sslCerts);
                    rep->setSslConfiguration(sslConfig);

                    // ignore only this ssl error
                    rep->ignoreSslErrors(expectedSslErrors);
                } else {
                    QLOG_ERROR() << "Network: Can not decode cert to DER.";
                }
            } else {
                int addCheck = aegis_certman_add_cert(ownDomain, crt);
                QLOG_INFO() << "Network Add Cert: " << addCheck;


                // convert internal X509 structure to DER
                int len;
                unsigned char *buf;

                buf = NULL;

                len = i2d_X509(crt, &buf);

                if (len > 0) {
                    // create Qt Certificate from buffer
                    QByteArray buffer(reinterpret_cast<const char*>(buf), len);
                    QSslCertificate sslCert(buffer, QSsl::Der);

                    // create list and append cert
                    QList<QSslCertificate> sslCerts;
                    sslCerts.append(sslCert);

                    // put ssl into ssl error for ignored errors
                    QSslError sslError(QSslError::SelfSignedCertificate, sslCerts.at(0));
                    QList<QSslError> expectedSslErrors;
开发者ID:Buschtrommel,项目名称:ocNews,代码行数:67,代码来源:ocnetwork.cpp

示例15: tr

MobileDialog::MobileDialog( QWidget *parent )
:	QDialog( parent )
{
	mobileResults["START"] = tr("Signing in process");
	mobileResults["REQUEST_OK"] = tr("Request accepted");
	mobileResults["EXPIRED_TRANSACTION"] = tr("Request timeout");
	mobileResults["USER_CANCEL"] = tr("User denied or cancelled");
	mobileResults["SIGNATURE"] = tr("Got signature");
	mobileResults["OUTSTANDING_TRANSACTION"] = tr("Request pending");
	mobileResults["MID_NOT_READY"] = tr("Mobile-ID not ready, try again later");
	mobileResults["PHONE_ABSENT"] = tr("Phone absent");
	mobileResults["SENDING_ERROR"] = tr("Request sending error");
	mobileResults["SIM_ERROR"] = tr("SIM error");
	mobileResults["INTERNAL_ERROR"] = tr("Service internal error");
	mobileResults["OCSP_UNAUTHORIZED"] = tr("Not allowed to use OCSP service!<br/>Please check your server access sertificate.");
	mobileResults["HOSTNOTFOUND"] = tr("Connecting to SK server failed!<br/>Please check your internet connection.");
	mobileResults["User is not a Mobile-ID client"] = tr("User is not a Mobile-ID client");
	mobileResults["ID and phone number do not match"] = tr("ID and phone number do not match");
	mobileResults["Certificate status unknown"] = tr("Your Mobile-ID service is not activated.");
	mobileResults["Certificate is revoked"] = tr("Mobile-ID user certificates are revoked or suspended.");

	setupUi( this );
	code->setBuddy( signProgressBar );

	statusTimer = new QTimeLine( signProgressBar->maximum() * 1000, this );
	statusTimer->setCurveShape( QTimeLine::LinearCurve );
	statusTimer->setFrameRange( signProgressBar->minimum(), signProgressBar->maximum() );
	connect( statusTimer, SIGNAL(frameChanged(int)), signProgressBar, SLOT(setValue(int)) );
	connect( statusTimer, SIGNAL(finished()), SLOT(endProgress()) );

	manager = new QNetworkAccessManager( this );
	connect( manager, SIGNAL(finished(QNetworkReply*)), SLOT(finished(QNetworkReply*)) );
	connect( manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
		SLOT(sslErrors(QNetworkReply*,QList<QSslError>)) );

	if( !Application::confValue( Application::ProxyHost ).toString().isEmpty() )
	{
		manager->setProxy( QNetworkProxy(
			QNetworkProxy::HttpProxy,
			Application::confValue( Application::ProxyHost ).toString(),
			Application::confValue( Application::ProxyPort ).toUInt(),
			Application::confValue( Application::ProxyUser ).toString(),
			Application::confValue( Application::ProxyPass ).toString() ) );
	}

	if( !Application::confValue( Application::PKCS12Disable ).toBool() )
	{
		QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
		ssl.setCaCertificates( ssl.caCertificates()
#ifdef Q_OS_LINUX
			<< QSslCertificate::fromPath( "/usr/share/esteid/certs/*.crt", QSsl::Pem, QRegExp::Wildcard )
#endif
			<< QSslCertificate( "-----BEGIN CERTIFICATE-----\n"
			"MIIEOzCCAyOgAwIBAgIBADANBgkqhkiG9w0BAQUFADB2MQswCQYDVQQGEwJFRTEi\n"
			"MCAGA1UEChMZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1czEeMBwGA1UECxMVU0sg\n"
			"c2VydmljZXMgYWNjZXNzIENBMSMwIQYDVQQDExpTSyBzZXJ2aWNlcyBhY2Nlc3Mg\n"
			"Q0EgMjAxMDAeFw0xMDAyMDcxNTIxMTBaFw0xOTEyMTcxNTIxMTBaMHYxCzAJBgNV\n"
			"BAYTAkVFMSIwIAYDVQQKExlBUyBTZXJ0aWZpdHNlZXJpbWlza2Vza3VzMR4wHAYD\n"
			"VQQLExVTSyBzZXJ2aWNlcyBhY2Nlc3MgQ0ExIzAhBgNVBAMTGlNLIHNlcnZpY2Vz\n"
			"IGFjY2VzcyBDQSAyMDEwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\n"
			"tkjCB8PkmDQRdtjbKDMJj5k6LPpFP3IUD+nCAHVhrpmU8FY3CfS/zBaFCnSlOxP3\n"
			"TZYlccBz5hcc7lSHSVxsVinW79aw/Sp4sUNVlhqB18UThHrdQiWznjQeOROpjjMo\n"
			"3WyW2lWlM3semodOSgD8ssSOUtHBeDLsHFdNrVuz6S1y2ulrfezcnDwrGOtWyYca\n"
			"MZzJZZbNA3cc6mXbvihkYv11o0yFdDrDatzjEVx2KrBaSDej2aPo9gES7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UFAAOCAQEAHqQ1FiZA1u8Qf1SHSZGpgjmy221x\n"
			"DkJ+gYNE0XRDbQ0G0FgqV8peHpIKxEYMGWVCNGRSIenyUYJDVqFMrqMZb1TaYYEg\n"
			"Mb5+u3aQpyp9gz3YGh45fvh73M/Pko4WjTsOaIJpXHzGZOSktiuVyEfEkRAupUhY\n"
			"7S4gJwPg6RIQXu/FfVCMtNyJliM/5Rz3+NeoLzZw4MVmjQGX0fxXDmVcbSkATqSx\n"
			"EV/PbuITu7jOJuDLEr5IpfJPgfl3vBYr2PSo5/2kypth0jikr4TVbGqLFlvU1DaH\n"
//.........这里部分代码省略.........
开发者ID:Krabi,项目名称:idkaart_public,代码行数:101,代码来源:MobileDialog.cpp


注:本文中的QSslConfiguration::setCaCertificates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。