Close #152: How can we specify the Cryptographic Service Provider
Some checks failed
CMake / build (build/xca-*-Linux.tar.gz, Unix Makefiles, linux, /usr, ubuntu, 5.15.2, ubuntu-latest) (push) Has been cancelled
CMake / build (build/xca-*-Linux.tar.gz, Unix Makefiles, linux, /usr, ubuntu, 6.6.2, ubuntu-latest) (push) Has been cancelled
CMake / build (build/xca-*.dmg, Unix Makefiles, mac, /opt/homebrew/opt/openssl, macos, 6.6.2, macos-latest) (push) Has been cancelled
CMake / build (build/xca-*.msi build/xca-portable-*.zip , MinGW Makefiles, windows, D:\msys2\msys64\mingw64, windows, 5.15.2, windows-2019, win64_mingw81) (push) Has been cancelled

A comment line of the format "CSP: <Provider Name>"
in the private key will be used as CSP during PKCS#12 / PFX
export.
This commit is contained in:
Christian Hohnstaedt 2024-09-30 19:07:12 +02:00
parent 1fe2c9907b
commit 53cbeea783
4 changed files with 22 additions and 4 deletions

View File

@ -106,6 +106,13 @@ Certificate Export
When exporting PKCS#12 structures XCA asks later for an encryption password.
Microsoft Cryptographic Service Provider (CSP)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The PKCS#12/PFX export function will include the CSP from the comment section
of the corresponding private key. The first line containing "CSP: <CSP Name>"
like **CSP: Microsoft Tatooine Sand Provider** will put the CSP Name into the PKCS#12 file.
Certificate Transformation
--------------------------

View File

@ -103,7 +103,6 @@ pki_pkcs12::pki_pkcs12(const QString &fname)
}
if (mykey) {
key = new pki_evp(mykey);
Q_CHECK_PTR(key);
key->setIntName(alias + "_key");
key->pkiSource = imported;
inheritFilename(key);
@ -159,10 +158,22 @@ void pki_pkcs12::writePKCS12(XFile &file, encAlgo &encAlgo) const
if (keyAlgoNid == NID_pbe_WithSHA1And40BitRC2_CBC)
keyAlgoNid = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
EVP_PKEY *pkey = key->decryptKey();
for (const QString &line : key->getComment().split('\n')) {
QStringList kv = line.split(":");
qDebug() << line << kv;
if (kv.size() != 2 || kv[0] != "CSP")
continue;
QByteArray csp = kv[1].trimmed().toLatin1();
EVP_PKEY_add1_attr_by_NID(pkey, NID_ms_csp_name,
MBSTRING_ASC, (const unsigned char*)csp.constData(), csp.size());
}
pkcs12 = PKCS12_create(pass.data(), getIntName().toUtf8().data(),
key->decryptKey(), cert->getCert(), certstack,
pkey, cert->getCert(), certstack,
keyAlgoNid, certAlgoNid, 0, 0, 0);
pki_openssl_error();
EVP_PKEY_free(pkey);
Q_CHECK_PTR(pkcs12);
if (encAlgo.legacy())

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>520</width>
<width>671</width>
<height>385</height>
</rect>
</property>

View File

@ -307,7 +307,7 @@ void CertDetail::itemChanged(pki_base *pki)
void CertDetail::showPubKey()
{
KeyDetail::showKey(this, myPubKey, false);
KeyDetail::showKey(this, myPubKey, keySqlId.isValid());
}
void CertDetail::showIssuer()