c# - Calling multiple webservices with different certificate types in a multithreaded environment -


my problem:

i have webapp (.net 4.5.1) doing multiple calls external webservices. of services communicates on ssl , other on tsl only.

i know that, reason, servicepointmanager.securityprotocol can set statically globaly appdomin (why global have no idea), since multiple calls can occure @ same time different external services in different threads - can't change securityprotcol appdomain each service call.

question:

how should handle in multithreaded web app environment? should make service calls spawn in different appdomains can set securityprotocol? , if - how should that?

i had problem , found solution worked me.

i use servicepointmanager handle connection certificates

servicepointmanager.servercertificatevalidationcallback = new system.net.security.remotecertificatevalidationcallback(validateremotecertificate);  private bool validateremotecertificate(object sender, x509certificate certificate, x509chain chain, sslpolicyerrors policyerrors)         {             ...         } 

to handle with different requests had dictionary mapping server urls task. each task runs asynchronously meaning don't have handle threads directly , inside each 1 used system.net objects. namely, httpwebrequest, ftpwebrequest , smtpwebrequest. each 1 of them has property enable/disable ssl connection worked same method validate certificates.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -