summaryrefslogtreecommitdiffstats
path: root/libcsoap
diff options
context:
space:
mode:
authorGravatar m0gg2006-11-29 13:01:00 +0000
committerGravatar m0gg2006-11-29 13:01:00 +0000
commit1b192076db396f83bf1a6be4957299e9eff46833 (patch)
tree23c158324de0cb9cff7e41c0a86ee7c30a98280e /libcsoap
parente4c2e3a011191c232521a2d4e6e5f71f983208fa (diff)
downloadcsoap-1b192076db396f83bf1a6be4957299e9eff46833.tar.gz
csoap-1b192076db396f83bf1a6be4957299e9eff46833.tar.bz2
Message signature verification added
Diffstat (limited to 'libcsoap')
-rw-r--r--libcsoap/soap-xmlsec.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/libcsoap/soap-xmlsec.c b/libcsoap/soap-xmlsec.c
index 55c341b..14b1a4e 100644
--- a/libcsoap/soap-xmlsec.c
+++ b/libcsoap/soap-xmlsec.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-xmlsec.c,v 1.5 2006/11/29 11:04:25 m0gg Exp $
+* $Id: soap-xmlsec.c,v 1.6 2006/11/29 13:01:00 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -865,7 +865,38 @@ herror_t soap_xmlsec_verify(struct SoapCtx *context)
{
if (!xmlStrcmp(walker->ns->href, "http://schemas.xmlsoap.org/soap/security/2000-12"))
{
- /* XXX do it */
+ xmlNodePtr node;
+ xmlSecDSigCtxPtr dsigCtx;
+
+ node = xmlSecFindNode(envelope->root, xmlSecNodeSignature, xmlSecDSigNs);
+ if (node == NULL)
+ {
+ log_error1("cannot find message signature");
+ return herror_new("soap_xmlsec_verify", 0, "message signature wasn't found");
+ }
+
+ dsigCtx = xmlSecDSigCtxCreate(_soap_xmlsec_key_manager);
+ if (dsigCtx == NULL)
+ {
+ log_error1("cannot create signature context");
+ return herror_new("soap_xmlsec_verify", 0, "cannot create signatur context");
+ }
+
+ if (xmlSecDSigCtxVerify(dsigCtx, node) < 0)
+ {
+ log_error1("xmlsecDSigCtxVerify failed");
+ return herror_new("soap_xmlsec_verify", 0, "verification failed");
+ }
+
+ if (dsigCtx->status == xmlSecDSigStatusSucceeded)
+ {
+ return H_OK;
+ }
+ else
+ {
+ log_error1("signature invalid");
+ return herror_new("soap_xmlsec_verify", 0, "signature invalid");
+ }
}
else
{