summaryrefslogtreecommitdiffstats
path: root/lasso
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-11-02 11:49:49 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-11-02 11:49:49 +0000
commit1032903f491db4069d37015100d4fda85906b158 (patch)
tree6600c4f9b347160f39ee3c1d7afa17e63bf99ef5 /lasso
parentec1e2946169e07ce6f3a2ce943ae7d0d228ce708 (diff)
downloadlasso-1032903f491db4069d37015100d4fda85906b158.tar.gz
lasso-1032903f491db4069d37015100d4fda85906b158.tar.xz
lasso-1032903f491db4069d37015100d4fda85906b158.zip
Add possibility to sign using preloaded keys
* lasso/xml/tools.c: - (lasso_sign_node) if loading of the private_key or the certificate file we try to use the filename directly as a key in the PEM format.
Diffstat (limited to 'lasso')
-rw-r--r--lasso/xml/tools.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c
index a61b7783..aa860104 100644
--- a/lasso/xml/tools.c
+++ b/lasso/xml/tools.c
@@ -747,12 +747,27 @@ lasso_sign_node(xmlNode *xmlnode, const char *id_attr_name, const char *id_value
xmlSecKeyDataFormatPem,
NULL, NULL, NULL);
if (dsig_ctx->signKey == NULL) {
+ int len = private_key_file ? strlen(private_key_file) : 0;
+
+ dsig_ctx->signKey = xmlSecCryptoAppKeyLoadMemory((xmlSecByte*)private_key_file, len,
+ xmlSecKeyDataFormatPem, NULL, NULL, NULL);
+ }
+ if (dsig_ctx->signKey == NULL) {
xmlSecDSigCtxDestroy(dsig_ctx);
return critical_error(LASSO_DS_ERROR_PRIVATE_KEY_LOAD_FAILED);
}
if (certificate_file != NULL && certificate_file[0] != 0) {
- if (xmlSecCryptoAppKeyCertLoad(dsig_ctx->signKey, certificate_file,
- xmlSecKeyDataFormatPem) < 0) {
+ int rc;
+
+ rc = xmlSecCryptoAppKeyCertLoad(dsig_ctx->signKey, certificate_file,
+ xmlSecKeyDataFormatPem);
+ if (rc < 0) {
+ int len = certificate_file ? strlen(certificate_file) : 0;
+
+ rc = xmlSecCryptoAppKeyCertLoadMemory(dsig_ctx->signKey, (xmlSecByte*)certificate_file,
+ len, xmlSecKeyDataFormatPem);
+ }
+ if (rc < 0) {
xmlSecDSigCtxDestroy(dsig_ctx);
return critical_error(LASSO_DS_ERROR_CERTIFICATE_LOAD_FAILED);
}