Assuming that you're defining ValidateServerCerificate as a member of a class 
you'll need to add a "self" parameter to it, eg:

class foo(object):
        def ValidateServerCertificate(self, sender, certificate, chain, 
sslPolicyErrors):
              return True

That will cause the expression "self.ValidateServerCertificate" to produce a 
bound method which contains the function + the reference to self and Python 
should be able to expose that method as a 4 parameter delegate which receives 
sender, certificate, chain, sslPolicyErrors.  Or you can just define VSC as a 
top-level function or a static method and not have it take self.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Garabatus Raptus
Sent: Wednesday, August 01, 2007 12:38 PM
To: Discussion of IronPython
Subject: Re: [IronPython] SslStream exception

Thanxs a lot.

Now, I'm having another issue ... I want to bypass the Validation of
the server  certificate but looks like the callback funtion is not
working properly.
Is this the way to create the Sslstream:

sslStream = SslStream( client.GetStream(), False,
RemoteCertificateValidationCallback ( self.ValidateServerCertificate),
None)

------------------

def ValidateServerCertificate( sender, certificate, chain, sslPolicyErrors):

      return True


regards,

gara


On 8/1/07, Dino Viehland <[EMAIL PROTECTED]> wrote:
> You have two options: You can catch a Python exception or a .NET exception, 
> and you'll get either the Python exception object or the .NET exception 
> object.  To catch a .NET exception as a Python exception you need to catch 
> the closest base exception which might be Exception or SystemError (if you 
> let the exception go unhandled it's whatever gets reported there).  To catch 
> the .NET exception you just need to grab it from the correct namespace, for 
> example:
>
> try:
>        # do something
> except System.ArgumentException, ex:
>        print ex
>
> and ex will end up being the ArgumentException instance.
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Garabatus 
> Raptus
> Sent: Wednesday, August 01, 2007 10:20 AM
> To: [email protected]
> Subject: [IronPython] SslStream exception
>
> Hi there,
>
> I'm new to IronPython and I would like to know how can I catch an
> exception generated by SslStream, Example:
>
> client = TcpClient(self.server, self.port)
>
> sslStream = SslStream( client.GetStream(), False,
> RemoteCertificateValidationCallback (self.ValidateServerCertificate),
> None)
>
> try:
>   sslStream.AuthenticateAsClient("secure.mydomain....")
> except <HERE?> :
>
>   ....  <HERE?> ...
>   return
>
> Is there any link where I can read about it and found some examples?
>
> regards,
>
> gara
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to