c# - Sending Client Certificate though HttpWebRequest, intermittenly working -
i have created web application calls web service requires client certificate authentication. here snippet of how building request:
// grab certificate x509certificate2 cert2 = new x509certificate2(appdomain.currentdomain.basedirectory + giftcardconfig.a2a_certificatelocation, giftcardconfig.a2a_certificatepassword, x509keystorageflags.machinekeyset); // first call status account stringbuilder urlstatus = new stringbuilder(giftcardconfig.a2a_url + "webservice.asp?"); urlstatus.append("userid=" + giftcardconfig.a2a_userid); urlstatus.append("&pwd=" + giftcardconfig.a2a_password); urlstatus.append("&sourceid=" + giftcardconfig.a2a_sourceid); urlstatus.append("&cardnum=" + cardnumber); urlstatus.append("&purseno=" + giftcardconfig.a2a_purseid); urlstatus.append("&status=activate"); // build http request httpwebrequest wrstatus = (httpwebrequest)webrequest.create(urlstatus.tostring()); wrstatus.keepalive = true; wrstatus.method = "get"; wrstatus.accept = "text/xml"; wrstatus.useragent = "mozilla/4.0 (compatible; msie 8.0; windows nt 5.2; trident/4.0; .net clr 1.1.4322; .net clr 1.0.3705; .net clr 2.0.50727; .net clr 3.0.04506.30; .net clr 3.0.04506.648; .net clr 3.0.4506.2152; .net clr 3.5.30729; .net4.0c; .net4.0e)"; wrstatus.clientcertificates.clear(); wrstatus.clientcertificates.add(cert2);
this works, intermittenly. every 24 hours server hosting web service returns 403:forbidden error. way fix iisreset of server running web application. stumped issue , know if issue has web application or configuration of server being hosted on.
any possible solutions or comments appreciated!
you try setting keep alive false, though there may performance hit this.
Comments
Post a Comment