QSslCertificate :: importPkcs12无法解析PFX文件 [英] QSslCertificate::importPkcs12 fails to parse PFX file

查看:336
本文介绍了QSslCertificate :: importPkcs12无法解析PFX文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在我的Qt应用程序中解压缩pkcs12文件-但没有运气.我正在构建 Qt控制台应用程序(已禁用GUI).

I'm trying to unpack my pkcs12 file in my Qt application - but having no luck. I'm building a Qt Console App (GUI disabled).

(我遵循了本指南: https://github.com/trueos/sysadm-ui-qt/blob/master/src-qt5/gui_client/SSLNotes.txt )

Pkcs12创建命令:

"openssl req -newkey rsa:2048 -nodes -keyout test_key.pem"
"openssl req -key test_key -new -x509 -out test_crt.crt"
"openssl pkcs12 -inkey test_key.pem -in test_crt.crt -export -passout stdin -out new.pfx"

Qt代码:

QString password="1234";
QFile pkcs("/Users/test/Desktop/certs/new.pfx");
pkcs.open(QFile::ReadOnly);
QSslKey key;
QSslCertificate cert;
QList<QSslCertificate> imported_certs;
static bool import=QSslCertificate::importPkcs12(&pkcs,&key,&cert,&imported_certs,QByteArray::fromStdString(password.toStdString()));

pkcs.close();
qDebug()<<import;

使用openssl命令手动提取了密钥和文件.

Manually extracting the key and the file have worked using openssl commands.

错误消息:

"Unimplemented Code."

有什么想法吗?

推荐答案

尝试使用Qt< 5.6就像Qt 5.5一样.

Try using Qt < 5.6 like Qt 5.5.

在Qt 5.6中,默认的SSL后端在Mac OS平台上从OpenSSL更改为Secure Transport.

In the Qt 5.6 the default SSL backend was changed from OpenSSL to Secure Transport on the Mac OS platform.

此问题已作为Bug填补: https://bugreports.qt.io/browse /QTBUG-56596

This problem already filled as a Bug: https://bugreports.qt.io/browse/QTBUG-56596

这篇关于QSslCertificate :: importPkcs12无法解析PFX文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆