std::vector<X509_Certificate> Credentials_Manager::cert_chain_single_type( const std::string& cert_key_type, const std::string& type, const std::string& context) { std::vector<std::string> cert_types; cert_types.push_back(cert_key_type); return cert_chain(cert_types, type, context); }
const QgsPkiBundle QgsPkiBundle::fromPkcs12Paths( const QString &bundlepath, const QString &bundlepass ) { QgsPkiBundle pkibundle; if ( QCA::isSupported( "pkcs12" ) && !bundlepath.isEmpty() && ( bundlepath.endsWith( QLatin1String( ".p12" ), Qt::CaseInsensitive ) || bundlepath.endsWith( QLatin1String( ".pfx" ), Qt::CaseInsensitive ) ) && QFile::exists( bundlepath ) ) { QCA::SecureArray passarray; if ( !bundlepass.isNull() ) passarray = QCA::SecureArray( bundlepass.toUtf8() ); QCA::ConvertResult res; QCA::KeyBundle bundle( QCA::KeyBundle::fromFile( bundlepath, passarray, &res, QStringLiteral( "qca-ossl" ) ) ); if ( res == QCA::ConvertGood && !bundle.isNull() ) { QCA::CertificateChain cert_chain( bundle.certificateChain() ); QSslCertificate cert( cert_chain.primary().toPEM().toLatin1() ); if ( !cert.isNull() ) { pkibundle.setClientCert( cert ); } QSslKey cert_key( bundle.privateKey().toPEM().toLatin1(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, QByteArray() ); if ( !cert_key.isNull() ) { pkibundle.setClientKey( cert_key ); } if ( cert_chain.size() > 1 ) { QList<QSslCertificate> ca_chain; Q_FOREACH ( const QCA::Certificate& ca_cert, cert_chain ) { if ( ca_cert != cert_chain.primary() ) { ca_chain << QSslCertificate( ca_cert.toPEM().toLatin1() ); } } pkibundle.setCaChain( ca_chain ); }