From f7c048d0eb4a95037a15fed51220151bfa8f5e5b Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Fri, 10 Jun 2022 14:28:41 +0200 Subject: [PATCH] zkey_kmip: Setup ext-lib once the APQNs have been configured MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During plugin initialization, the external libraries such as the EP11 or CCA host libraries are set up, if the configuration is appropriate. A secure identity key may be generated once the APQNs are configured, but before the server connection is configured. Trying to re-encipher the plugin's secure keys to a new HSM master key at that stage fails with 'ERROR: Invalid ext lib type: 0' because the external libraries have not been setup yet. Change the code to setup the libraries once the APQNs have been configured, and not only after the server connection has been configured. Signed-off-by: Ingo Franzki Signed-off-by: Jan Höppner --- zkey/kmip/zkey-kmip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zkey/kmip/zkey-kmip.c b/zkey/kmip/zkey-kmip.c index 5d071832..a00c5dd5 100644 --- a/zkey/kmip/zkey-kmip.c +++ b/zkey/kmip/zkey-kmip.c @@ -670,13 +670,16 @@ static int _get_kmip_config(struct plugin_handle *ph) char *tmp; int rc; - if (ph->server == NULL || ph->profile == NULL) + if (!ph->apqns_configured) return 0; rc = _setup_ext_lib(ph); if (rc != 0) return rc; + if (ph->server == NULL || ph->profile == NULL) + return 0; + rc = _get_client_key(ph, &ph->kmip_config.tls_client_key); if (rc != 0) return rc;