RE: [Bulk] Re: [Bulk] Re: [xmlsec] ErrorsCallback ???

2006-01-06 Thread Edward Shallow
Hi Aleksey,

   Thanks once again. The following worked when added to the ErrorsCallback
(mscrypto only) ...

errCode = win32api.GetLastError()
errMsg = win32api.FormatMessage(errCode)

Ed 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Edward Shallow
Sent: January 6, 2006 12:07 PM
To: xmlsec@aleksey.com
Subject: RE: [Bulk] Re: [Bulk] Re: [xmlsec] ErrorsCallback ???

 Oh I see. You mean the Windows Win32::GetLastError() call. I do not mind
trying this as a work-around. I'll let you know. I think the ideal would be
to normalize the error handling as you suggested.

Thanks,
Ed

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Aleksey Sanin
Sent: January 6, 2006 12:00 PM
To: [EMAIL PROTECTED]
Cc: xmlsec@aleksey.com
Subject: [Bulk] Re: [Bulk] Re: [xmlsec] ErrorsCallback ???



> The xmlGetLastError seemed very attractive and it does work perfectly 
> for all libxml2 calls and returns output which is identical to stderr.

The message on std err from xmlsec is printed by LibXML2. I can not test it
on Windows at the moment, but I can get back all this information using
xmlGetLastError() on Linux.


As I wrote you before, the "extra" information you see is provided from
*system* GetLasstError() call. You can make same call from python inside
your error callback.


Aleksey

___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


RE: [Bulk] Re: [Bulk] Re: [xmlsec] ErrorsCallback ???

2006-01-06 Thread Edward Shallow
 Oh I see. You mean the Windows Win32::GetLastError() call. I do not mind
trying this as a work-around. I'll let you know. I think the ideal would be
to normalize the error handling as you suggested.

Thanks,
Ed

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Aleksey Sanin
Sent: January 6, 2006 12:00 PM
To: [EMAIL PROTECTED]
Cc: xmlsec@aleksey.com
Subject: [Bulk] Re: [Bulk] Re: [xmlsec] ErrorsCallback ???



> The xmlGetLastError seemed very attractive and it does work perfectly 
> for all libxml2 calls and returns output which is identical to stderr.

The message on std err from xmlsec is printed by LibXML2. I can not test it
on Windows at the moment, but I can get back all this information using
xmlGetLastError() on Linux.


As I wrote you before, the "extra" information you see is provided from
*system* GetLasstError() call. You can make same call from python inside
your error callback.


Aleksey

___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


Re: [Bulk] Re: [xmlsec] ErrorsCallback ???

2006-01-06 Thread Aleksey Sanin




The xmlGetLastError seemed very attractive and it does work perfectly for
all libxml2 calls and returns output which is identical to stderr. 


The message on std err from xmlsec is printed by LibXML2. I can not test
it on Windows at the moment, but I can get back all this information
using xmlGetLastError() on Linux.


As I wrote you before, the "extra" information you see is provided from
*system* GetLasstError() call. You can make same call from python inside
your error callback.


Aleksey

___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


RE: [Bulk] Re: [Bulk] Re: [xmlsec] ErrorsCallback ???

2006-01-06 Thread Edward Shallow
Hi Aleksey,

Yes that is correct. When I do "not" set the callback, I get verbose error
messages on stderr. I never see the specific "error msg=The specified
network password is not correct" coming to the callback. The callback when
it does receive a msg is not as verbose as what goes to stderr. See output
examples from my previous post. 6 out of the 7 arguments work perfectly all
the time, it is just the last argument i.e. msg that is inconsistent.

No ErrorsCallback set
*

func=xmlSecMSCryptoAppPkcs12LoadMemory:file=..\src\mscrypto\app.c:line=614:o
bj=unknown:subj=PFXVerifyPassword:error=4:crypto library function failed:
;last error=86 (0x0056);last error msg=The specified network password is
not correct.

func=xmlSecMSCryptoAppPkcs12Load:file=..\src\mscrypto\app.c:line=522:obj=unk
nown:subj=xmlSecMSCryptoAppPkcs12LoadMemory:error=1:xmlsec library function
failed: ;last error=86 (0x0056);last error msg=The specified network
password is not correct.

func=xmlSecMSCryptoAppKeyLoad:file=..\src\mscrypto\app.c:line=128:obj=unknow
n:subj=xmlSecMSCryptoAppPkcs12Load:error=1:xmlsec library function failed:
;last error=86 (0x0056);last error msg=The specified network password is
not correct.


   

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Aleksey Sanin
Sent: January 5, 2006 11:43 PM
To: [EMAIL PROTECTED]
Cc: xmlsec@aleksey.com
Subject: [Bulk] Re: [Bulk] Re: [xmlsec] ErrorsCallback ???

Do you see the error message on stderr?

Aleksey

Edward Shallow wrote:
> PostScript ...
> 
>  A call to the following works fine after any libxml2 function 
> throwing an error. I tried it after a failed xmlsec function call and 
> received nothing (i.e. Python None aka NULL)
> 
> Ed
> 
___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


RE: [Bulk] Re: [xmlsec] ErrorsCallback ???

2006-01-06 Thread Edward Shallow
 Thanks for your patience,

   All I would like to do is trap the most informative message in whatever
way works, I am not fussy. In this simple password example it would be "The
specified network password is not correct" message. Neither of 1) setting
ErrorsCallback or 2) using xmlGetLastError is working for me. This is true
of both openssl and mscrypto. With the ErrorsCallback set, mscrypto returns
nothing in the msg argument, and openssl returns the offending p12 file
name. I think it makes sense to get back the more informative "The specified
network password is not correct" message.

   The best would be to get at this "most informative" msg which always goes
to stderr perfectly, but can't be trappped in any easy way programmatically.
The xmlGetLastError seemed very attractive and it does work perfectly for
all libxml2 calls and returns output which is identical to stderr. 

Hope this helps,
Ed   

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Aleksey Sanin
Sent: January 6, 2006 12:01 AM
To: [EMAIL PROTECTED]
Cc: xmlsec@aleksey.com
Subject: [Bulk] Re: [xmlsec] ErrorsCallback ???

Ed,

I think I found the reason for your confusion. In the first email in this
thread you gave several example for MSCrypto error messages with and without
errors callback set. I'll pick one of them and will explain the problem:

mscrypto


epmErrorCallback xmlsec error follows:
file..\src\mscrypto\app.c
line614
funcxmlSecMSCryptoAppPkcs12LoadMemory
errorObject None
errorSubjectPFXVerifyPassword
reason  4
msg

No ErrorsCallback set
*

func=xmlSecMSCryptoAppPkcs12LoadMemory:file=..\src\mscrypto\app.c:line=614:o
bj=unknown:subj=PFXVerifyPassword:error=4:crypto library function failed:
;last error=86 (0x0056);last error msg=The specified network password is
not correct.



The 'msg' you see in the first case (with epmErrorsCallback) is provided by
the xmlsec-mscrypto (or xmlsec-openssl) author. If you go to the
corresponding file, you'll see that there is *no* message provided in this
case thus you observe correct results.

The messages you see in the second case (no custom ErrorsCallback) are
created by xmlSecMSCryptoErrorsDefaultCallback() function which is *the*
default errors callback when xmlsec-mscrypto is used (yes, it is a little
bit confusing :( ). This function simply calls Windows
GetLastError() and FormatMessage() to generate the

   "last error=86 (0x0056);last error msg=The specified network
password is not correct."

message and append it to *all* error messages.


I agree, this is confusing but the system does what it was written to do.
May be a better approach would be to move this "extra"
xmlSecMSCryptoErrorsDefaultCallback() functionality into the generic
xmlSecErrorsDefaultCallback() and just ifdef it for Windows only.
Then the output will be consistent between different crypto libraries.


Aleksey





___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


Re: [Bulk] Re: [xmlsec] ErrorsCallback ???

2006-01-05 Thread Aleksey Sanin

Do you see the error message on stderr?

Aleksey

Edward Shallow wrote:

PostScript ...

 A call to the following works fine after any libxml2 function throwing
an error. I tried it after a failed xmlsec function call and received
nothing (i.e. Python None aka NULL)

Ed


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


RE: [Bulk] Re: [xmlsec] ErrorsCallback ???

2006-01-05 Thread Edward Shallow
PostScript ...

 A call to the following works fine after any libxml2 function throwing
an error. I tried it after a failed xmlsec function call and received
nothing (i.e. Python None aka NULL)

Ed



errMsg = self.checkLibxml2Error()

...

def checkLibxml2Error(self):
libxml2 = self.env.libxml2
errMsg = None
errorPtr = libxml2.xmlGetLastError()
if errorPtr != 0:
try:
error = xmlError.from_address(errorPtr) #
set up pointer to a libxml2 xmlError structure
errMsg = 'level ' + str(error.level) + ' error in domain ' +
str(error.domain) + ' code ' + str(error.code) + error.message, ' at line '
+ str(error.line)
except:
errMsg = 'Fatal error in xmlGetLastError function'
return errMsg

 

-Original Message-
From: Edward Shallow [mailto:[EMAIL PROTECTED] 
Sent: January 5, 2006 11:02 PM
To: 'Aleksey Sanin'
Subject: RE: [Bulk] Re: [xmlsec] ErrorsCallback ???

Re 2,  Yes that sounds good !!! I'll try the xmlGetLastError support for
xmlsec as well. I am already using it for libxml2 parsing errors.

Re 1, Yes I am using Python with the ctypes module to directly access
libxml2 and xmlsec. I can set the breakpoint on Linux but my problem is
mscrypto and on Windows I am using Igor's binaries. I have never compiled
under Windows, don't have the patience or the software.

I doubt there is a coding problem as everything is coming back for openssl
and sometimes is coming back for mscrypto (Verify calls)

Ed 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Aleksey Sanin
Sent: January 5, 2006 7:51 PM
To: [EMAIL PROTECTED]
Cc: xmlsec@aleksey.com
Subject: [Bulk] Re: [xmlsec] ErrorsCallback ???

1) Are you using xmlsec directly or via python? If you have C/C++ app,
simply set a  breakpoint in the error callback and then trace it back to the
error origin. You'll see the exact place where NULL shows up.

2) The default callback sets the reported error in to libxml2 thus you can
use xmlGetLastError() directly. If you have a custom callback then you can
do similar thing yourself.

Aleksey


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec


___
xmlsec mailing list
xmlsec@aleksey.com
http://www.aleksey.com/mailman/listinfo/xmlsec