紧急求助https连接的问题

nkdominic 2013-05-09 11:17:16
刚开始学Qt,要从客户端用https连接服务器端,下面是我的代码:
QString req = "https://192.168.3.8/api";
QUrl urlTemp(req);
urlTemp.setPort(443);

QNetworkRequest request(urlTemp);
QSslConfiguration sslConfiguration = request.sslConfiguration();
sslConfiguration.setProtocol(QSsl::AnyProtocol);
sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyPeer); //必须要验证数字证书,所以不能用QSslSocket::VerifyNone或者QSslSocket::QueryPeer模式

QList<QSslCertificate> certs = sslConfiguration.caCertificates();
certs.append(QSslCertificate::fromPath(QLatin1String("d:\\ca.pem"), QSsl::Pem));
sslConfiguration.setCaCertificates(certs);
request.setSslConfiguration(sslConfiguration);

QNetworkAccessManager manager;
connect(&manager,SIGNAL(finished(QNetworkReply*)),
this,SLOT(slotFinished(QNetworkReply*)));
其中d:\\ca.pem是我保存的服务器端的数字证书。
但是在slotFinished()里面总是收到SslHandshakeFailedError,高手帮我看看,问题出在什么地方。
...全文
58 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
chuachua66 2013-05-09
  • 打赏
  • 举报
回复
去QT区问啊!

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧