My C# program is connecting to VMware VirtualCenter web service with https
protocal. After it estenblishes a web service connection to the server, it
can clone multiple virtaul machines. It works fine if the cloning operation
is taking one by one sequentially in the main thread. If I create multiple
threads to do the task, some thread will cause AuthenticationException with
additional information: The remote certificate is invalid according to the
validation procedure.
Then it throws WebException: The underlying connection was closed: Could not
establish trust relationship for the SSL/TLS secure channel.
My code already implements this:
ServicePointManager.ServerCertificateValidationCallback = new delegate { return true; };
vimService.CookieContainer = new CookieContainer();
I guess the separate threads run in different contexts that cannot maintain
the connection credential. I don't know how to fix this.
Any advise is greatly appreciated.
Does each thread login to Virtual Center OR do they share a single login session?
They share a login session.
I use multiple threads successfully but each thread establishes its own login session. IOW, no session sharing. My code is in java but I'm not sure if that makes any difference.
If you eliminate session sharing please share the results here. I'm curious about C#, thanks.
There doesn't seem to be any issue in using the same connection in multiple child threads. Can you post your code here?
After I set the callback to ServicePointManager.ServerCertificateValidationCallback in each thread, the problem is gone.
Thanks for all replies.
