1、编译openssl
下载地址:
我这里是mips平台,用mipsel的工具链就ok了,具体编译参数可参照configure -h
另外在编译的时候出现"dummy unreference error",简单地处理方法可以在crypto/cryptlib.c添加
void *dummy(){return;}
2、编译qt
configure -openssl -I/usr/local/include
或
OPENSSL_LIBS='-L/usr/local/ssl/lib -lssl -lcrypto' ./configure -openssl-linked
在编译时qt会检查openssl/opensslv.h文件
3、测试
cd demo/browser
./browser
4、忽略sslError
在经过上述操作之后,打开gmail时会弹出一个消息框,是否忽略ssl错误,相应的处理代码在demo/browser/networkaccessmanager.cpp
void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
{
// check if SSL certificate has been trusted already
QString replyHost = reply->url().host() + ":" + reply->url().port();
if(! sslTrustedHostList.contains(replyHost)) {
BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
QStringList errorStrings;
for (int i = 0; i < error.count(); ++i)
errorStrings += error.at(i).errorString();
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 for this host?").arg(reply->url().toString()).arg(errors),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if (ret == QMessageBox::Yes) {
reply->ignoreSslErrors();
sslTrustedHostList.append(replyHost);
}
}
} |
如果想在代码中忽略这些错误可以这样,并且去掉QMessageBox
reply->ignoreSslErrors(error);
5、如何在iis上搭建https server
http://blog.csdn.net/antsnm/archive/2009/12/15/5009010.aspx
阅读(3783) | 评论(0) | 转发(0) |