Hi Aleksey,<br><br>I tried to verify the test file which is placed on your website at [<a href="http://www.aleksey.com/xmlsec/tests/aleksey-xmldsig-01/enveloping-dsa-x509chain.xml">http://www.aleksey.com/xmlsec/tests/aleksey-xmldsig-01/enveloping-dsa-x509chain.xml</a>] using online tool present on your site as well as using a locally placed xmlsec.exe. The command i am using locally is <br>
<br>xmlsec.exe --verify signature.xml [Please tell me if I am not using the command correctly]<br><br>I error I get is still the same after all the different efforts i have put in.<br><br>The current procedure i am following is:<br>
<br>1. Read the signature.xml file and add each certificate as trusted pem.<br>2. in X509_vfy.c, i would delete all the certs which are not self-signed or intermediate CA.<br><br>The verification succeeds in this way of verification. <br>
The risk i see in this process is that I am simply trusting any certificates that are present in the signature.xml which is a big threat.<br><br>Will be extremely glad to know your response at your earliest.<br><br>Regards,<br>
Naval.<br><br><br><div class="gmail_quote">On Wed, Dec 22, 2010 at 11:32 AM, Naval Patel <span dir="ltr"><<a href="http://www.naval.com">www.naval.com</a>@<a href="http://gmail.com">gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
This is the error when root CA is in the signed xml<br><br>func=xmlSecOpenSSLX509StoreVerify:file=d:\svn_simulator\white\products\76xx\app\module\wrtconfig\wrtconfig\external\libxmlsec\src\openssl\x509vfy<br>.c:line=360:obj=x509-store:subj=X509_verify_cert:error=4:crypto library function failed:subj=/C=IN/ST=Mah/L=Pune/O=Agreeya/OU=Almond/CN=rootca/emailAd<br>
dress=<a href="mailto:rootca@agreeya.com" target="_blank">rootca@agreeya.com</a>;err=19;msg=self signed certificate in certificate chain<br>func=xmlSecOpenSSLX509StoreVerify:file=d:\svn_simulator\white\products\76xx\app\module\wrtconfig\wrtconfig\external\libxmlsec\src\openssl\x509vfy<br>
.c:line=408:obj=x509-store:subj=unknown:error=71:certificate verification failed:err=19;msg=self signed certificate in certificate chain<br><br>this is the error when root ca is not in the signed xml, but passed explicitly as trusted.<br>
<br>func=xmlSecOpenSSLX509StoreVerify:file=d:\svn_simulator\white\products\76xx\app\module\wrtconfig\wrtconfig\external\libxmlsec\src\openssl\x509vfy<br>.c:line=360:obj=x509-store:subj=X509_verify_cert:error=4:crypto library function failed:subj=/C=IN/ST=Maharashtra/L=Pune/O=Agreeya/OU=Almond/CN=ca1/em<br>
ailAddress=<a href="mailto:ca1@agreeya.com" target="_blank">ca1@agreeya.com</a>;err=24;msg=invalid CA certificate<br>func=xmlSecOpenSSLX509StoreVerify:file=d:\svn_simulator\white\products\76xx\app\module\wrtconfig\wrtconfig\external\libxmlsec\src\openssl\x509vfy<br>
.c:line=408:obj=x509-store:subj=unknown:error=71:certificate verification failed:err=24;msg=invalid CA certificate<br><br><br>Thanks,<br>Naval.<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Wed, Dec 22, 2010 at 11:27 AM, Aleksey Sanin <span dir="ltr"><<a href="mailto:aleksey@aleksey.com" target="_blank">aleksey@aleksey.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Could you please copy/paste the complete error?<br>
<br>
Aleksey<div><br>
<br>
On 12/21/10 9:56 PM, Naval Patel wrote:<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>
If the entire cert chain is in the signed document the error i get is<br>
msg=self signed certificate in certificate chain<br>
<br>
if i remove the Root certificate from the chain in the signed xml file,<br>
and pass a root certificate as trusted, then i get the error as<br>
msg=invalid CA certificate<br>
<br>
is there something that i am missing or this is not the right way to do?<br>
<br>
thanks :)<br>
<br>
Naval.<br>
<br>
On Tue, Dec 21, 2010 at 9:24 PM, Aleksey Sanin <<a href="mailto:aleksey@aleksey.com" target="_blank">aleksey@aleksey.com</a><br></div><div><div></div><div>
<mailto:<a href="mailto:aleksey@aleksey.com" target="_blank">aleksey@aleksey.com</a>>> wrote:<br>
<br>
What errors do you get?<br>
<br>
Aleksey<br>
<br>
<br>
On 12/21/10 12:38 AM, Naval Patel wrote:<br>
<br>
Hi,<br>
<br>
Its been quite some time i am modifying my code to allow a<br>
signed xml<br>
document containing the entire chain of certificates from "Local<br>
cert"<br>
through CAs and ultimately the Root CA. I have debugged the code<br>
till<br>
the call goes to *X509_verify_cert(&xsc)*. I have observed that<br>
for each<br>
*<X509Certificate> *the xmlsec adds the certificate to the<br>
X509_STACK.<br>
The function call (*xmlSecOpenSSLX509FindNextChainCert*) inside<br>
the *for<br>
loop* inside the function *xmlSecOpenSSLX509StoreVerify* with the<br>
comment [/* get one cert after another and try to verify */] returns<br>
NULL only when it finds that the certificate does not extend any<br>
other<br>
certificates.<br>
<br>
I have RootCa.pem > CA1.pem > CA2.pem > signerCert.pem.<br>
<br>
If i simply execute the signeddoc.xml, I am receiving the error<br>
[*msg=invalid CA certificate* for CA2.pem] ... the command used is<br>
*xmlsec.exe verify --trusted-pem RootCa.pem signeddoc.xml*<br>
I broke the certificate chain by removing RootCa.pem from the<br>
signeddoc.xml and the error i received is same as of the above case<br>
*xmlsec.exe verify --trusted-pem RootCa.pem signeddoc.xml<br>
*I changed the command for the above file as *xmlsec.exe verify<br>
--trusted-pem RootCa.pem --trusted-pem CA2.pem signeddoc.xml*,<br>
still the<br>
error was same<br>
I maintained only CA1, CA2 and signerCert.pem in signeddoc.xml<br>
and used<br>
the command *xmlsec.exe verify --trusted-pem RootCa.pem<br>
--trusted-pem<br>
CA1.pem --trusted-pem CA2.pem signeddoc.xml<br>
*Now I removed CA2 from the signeddoc.xml and kept only CA1 and<br>
signerCert.pem, and used the command *xmlsec.exe verify<br>
--trusted-pem<br>
RootCa.pem --trusted-pem CA1.pem --trusted-pem CA2.pem<br>
signeddoc.xml ...<br>
*i could see that the verification was passing.<br>
<br>
I have deviced another way too to make this work, but i am not<br>
sure how<br>
good this way is...<br>
<br>
before passing the signeddoc.xml to xmlsec, I load the<br>
x509certificate<br>
as trusted using the api *xmlSecCryptoAppKeysMngrCertLoadMemory*<br>
but the<br>
problem is not solved because the same document continues to be<br>
evaluated by xmlsec later and the results produced are same.<br>
<br>
Another alternative i thought was once the function<br>
*xmlSecOpenSSLX509FindNextChainCert *returns NULL, I would<br>
remove the<br>
other certificates from the STACK. That way, i will have trusted<br>
certs<br>
loaded to the global stack and while signerCert.pem is verified.<br>
<br>
Please let me know your suggestions, I will try your suggested<br>
methods.<br>
<br>
And thanks a lot for this library, it had done wonders for my<br>
work till<br>
now :)<br>
<br>
I had read an email from the archive<br>
[*<a href="http://www.aleksey.com/pipermail/xmlsec/2008/008326.html*" target="_blank">http://www.aleksey.com/pipermail/xmlsec/2008/008326.html*</a>], but i<br>
could not get the break through yet :(<br>
<br>
Regards,<br>
Naval<br>
<br>
<br>
<br>
_______________________________________________<br>
xmlsec mailing list<br></div></div>
<a href="mailto:xmlsec@aleksey.com" target="_blank">xmlsec@aleksey.com</a> <mailto:<a href="mailto:xmlsec@aleksey.com" target="_blank">xmlsec@aleksey.com</a>><div><br>
<a href="http://www.aleksey.com/mailman/listinfo/xmlsec" target="_blank">http://www.aleksey.com/mailman/listinfo/xmlsec</a><br>
<br>
<br>
<br>
<br>
--<br>
Naval Patel<br>
~ have fun ~<br>
</div></blockquote>
</blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br>Naval Patel<br>~ have fun ~<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Naval Patel<br>~ have fun ~<br>