From adf6e9cb01bd7bd3cb73f76afd05fdb08a6468a6 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 10 Nov 2008 16:57:36 +0000 Subject: Add support to in memory private key to lasso_query_sign - lasso/xml/tools.c: use BIO_new_mem_buf instead of BIO_new_file if private_key is not an existing file. --- lasso/xml/tools.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c index 07dbd9c0..c72112be 100644 --- a/lasso/xml/tools.c +++ b/lasso/xml/tools.c @@ -381,7 +381,12 @@ lasso_query_sign(char *query, LassoSignatureMethod sign_method, const char *priv sign_method == LASSO_SIGNATURE_METHOD_DSA_SHA1, NULL); g_return_val_if_fail(private_key_file != NULL, NULL); - bio = BIO_new_file(private_key_file, "rb"); + if (access(private_key_file, R_OK) == 0) { + bio = BIO_new_file(private_key_file, "rb"); + } else { + // Safe deconst cast, the BIO is read-only + bio = BIO_new_mem_buf((char*)private_key_file, -1); + } if (bio == NULL) { message(G_LOG_LEVEL_CRITICAL, "Failed to open %s private key file", private_key_file); -- cgit