qt5base-lts/tests/auto/network/ssl/qsslkey
Mårten Nordheim f8e551cf08 Fix loading pkcs#8 encrypted DER-encoded keys in openssl
When we load DER-encoded keys in the openssl-backend we always turn it
into PEM-encoded keys (essentially we prepend and append a header and
footer and use 'toBase64' on the DER data).

The problem comes from the header and footer which is simply chosen
based on which key algorithm was chosen by the user. Which would be
wrong when the key is a PKCS#8 key. This caused OpenSSL to fail when
trying to read it. Surprisingly it still loads correctly for unencrypted
keys with the wrong header, but not for encrypted keys.

This patch adds a small function which checks if a key is an encrypted
PKCS#8 key and then uses this function to figure out if a PKCS#8 header
and footer should be used (note that I only do this for encrypted PKCS#8
keys since, as previously mentioned, unencrypted keys are read correctly
by openssl).

The passphrase is now also passed to the QSslKeyPrivate::decodeDer
function so DER-encoded files can actually be decrypted.

[ChangeLog][QtNetwork][QSslKey] The openssl backend can now load
encrypted PKCS#8 DER-encoded keys.

Task-number: QTBUG-17718
Change-Id: I52eedf19bde297c9aa7fb050e835b3fc0db724e2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-04-11 14:30:08 +00:00
..
keys Fix loading pkcs#8 encrypted DER-encoded keys in openssl 2018-04-11 14:30:08 +00:00
.gitignore Moved network autotests into new directory structure 2011-09-09 09:32:17 +02:00
BLACKLIST Unblacklist qsslkey for Linux 2018-04-09 09:34:50 +00:00
qsslkey.pro Use TESTDATA for QSsl* tests 2018-01-12 11:43:55 +00:00
rsa-with-passphrase-3des.pem ssl: add a test for 3DES encrypted keys 2014-08-30 17:24:05 +02:00
rsa-with-passphrase-des.pem ssl: add a test for 3DES encrypted keys 2014-08-30 17:24:05 +02:00
rsa-with-passphrase-rc2.pem ssl: common key parser support for encrypted keys 2014-09-02 23:16:25 +02:00
rsa-without-passphrase.pem Moved network autotests into new directory structure 2011-09-09 09:32:17 +02:00
tst_qsslkey.cpp Fix loading pkcs#8 encrypted DER-encoded keys in openssl 2018-04-11 14:30:08 +00:00