diff options
author | Philippe Mathieu-Daudé <philmd@redhat.com> | 2021-06-28 18:09:10 +0200 |
---|---|---|
committer | Michael Roth <michael.roth@amd.com> | 2021-10-14 16:27:19 -0500 |
commit | 8d5c255a2569b01c56b32783da93b1c2f15c7deb (patch) | |
tree | bd8281d02447bdc50205c1ff3705872cbdef8e65 | |
parent | 738ff4bf07304399d3d830afd4b5e3296fbb3cce (diff) |
qemu-nbd: Use qcrypto_tls_creds_check_endpoint()
Avoid accessing QCryptoTLSCreds internals by using
the qcrypto_tls_creds_check_endpoint() helper.
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 0279cd9535283cf5711768ab6401b204e5697a81)
Signed-off-by: Michael Roth <michael.roth@amd.com>
-rw-r--r-- | qemu-nbd.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c index 93ef4e288f..26ffbf15af 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -43,6 +43,7 @@ #include "io/channel-socket.h" #include "io/net-listener.h" #include "crypto/init.h" +#include "crypto/tlscreds.h" #include "trace/control.h" #include "qemu-version.h" @@ -422,18 +423,12 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list, return NULL; } - if (list) { - if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) { - error_setg(errp, - "Expecting TLS credentials with a client endpoint"); - return NULL; - } - } else { - if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { - error_setg(errp, - "Expecting TLS credentials with a server endpoint"); - return NULL; - } + if (!qcrypto_tls_creds_check_endpoint(creds, + list + ? QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT + : QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, + errp)) { + return NULL; } object_ref(obj); return creds; |