summaryrefslogtreecommitdiffstats
path: root/lasso
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-11-10 16:57:36 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-11-10 16:57:36 +0000
commitadf6e9cb01bd7bd3cb73f76afd05fdb08a6468a6 (patch)
tree64a4d0a7148480b0452b882e6ce600a93c15c87e /lasso
parentd01eec1b57ca30551fd501f88fb89272b898d19a (diff)
downloadlasso-adf6e9cb01bd7bd3cb73f76afd05fdb08a6468a6.tar.gz
lasso-adf6e9cb01bd7bd3cb73f76afd05fdb08a6468a6.tar.xz
lasso-adf6e9cb01bd7bd3cb73f76afd05fdb08a6468a6.zip
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.
Diffstat (limited to 'lasso')
-rw-r--r--lasso/xml/tools.c7
1 files changed, 6 insertions, 1 deletions
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);