diff options
author | Lars Schmertmann <lars.schmertmann@governikus.com> | 2016-06-10 12:07:53 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-07-28 14:32:05 +0000 |
commit | 7f77dc84fb434f33ffe96f6633792706b80fb0a3 (patch) | |
tree | 0c6cbb6605d0ba65c3bf5a07e0bf313d19358837 /src/network/ssl/qsslkey_p.cpp | |
parent | 997fa05d90e9e1bc02615044fd4f042cb212be65 (diff) |
Store QSslKey in specific key format to provide more details for key
In a TLS handshake the ephemeral server key is saved in the ssl
configuration. Clients who want to get the length or algorithm of the
key only get "Opaque" and "-1" as a result because the key is always
stored as "Opaque". This change converts the key to specific type so
more details are available and the client don't need to convert the
handle by hand.
Change-Id: I60f90fc2c1805e528640d391b20c676b6eeeb49e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'src/network/ssl/qsslkey_p.cpp')
-rw-r--r-- | src/network/ssl/qsslkey_p.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/network/ssl/qsslkey_p.cpp b/src/network/ssl/qsslkey_p.cpp index 34f664093c..e66ec953a0 100644 --- a/src/network/ssl/qsslkey_p.cpp +++ b/src/network/ssl/qsslkey_p.cpp @@ -56,6 +56,9 @@ #include "qsslkey.h" #include "qsslkey_p.h" +#ifndef QT_NO_OPENSSL +#include "qsslsocket_openssl_symbols_p.h" +#endif #include "qsslsocket.h" #include "qsslsocket_p.h" @@ -277,18 +280,23 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding \a type specifies whether the key is public or private. QSslKey will take ownership for this key and you must not - free the key using the native library. The algorithm used - when creating a key from a handle will always be QSsl::Opaque. + free the key using the native library. */ QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type) : d(new QSslKeyPrivate) { #ifndef QT_NO_OPENSSL - d->opaque = reinterpret_cast<EVP_PKEY *>(handle); + EVP_PKEY *evpKey = reinterpret_cast<EVP_PKEY *>(handle); + if (!evpKey || !d->fromEVP_PKEY(evpKey)) { + d->opaque = evpKey; + d->algorithm = QSsl::Opaque; + } else { + q_EVP_PKEY_free(evpKey); + } #else d->opaque = handle; -#endif d->algorithm = QSsl::Opaque; +#endif d->type = type; d->isNull = !d->opaque; } |