I
Ian
I've a got an IIS web service that accesses a remote IIS site to get
information from and I'm trying to get the web service to use a client
certificate. If the remote IIS site is set up to ignore the client
ceritficate then the request works with no problem. If I set the remote IIS
site to accept the client certificate then I get a HTTP 403 forbidden error,
and in the event log I get an event ID 1309 for the web service with the text
"Server cannot clear headers after HTTP headers have been sent. Below is an
extract from my web service code and I can't for the life of me figure what
the problem is:
ServicePointManager.ServerCertificateValidationCallback = new
RemoteCertificateValidationCallback(VerifyServerCertificate);
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(strUri);
webRequest.Credentials = new NetworkCredential(strUserName, strPassword,
strDomain);
this.GetClientCertificate(webRequest); // adds the client certificate to the
request
AddHeadersToRequest(additionalHeaders, webRequest); // adds Range header etc
webRequest.Method = strMethodName;
if (0 != baRequestBody.Length)
{
webRequest.ContentLength = baRequestBody.Length;
Stream requestStream = webRequest.GetRequestStream();
requestStream.Write(baRequestBody, 0, baRequestBody.Length);
requestStream.Close();
}
AddContentTypeToRequest(contentType, webRequest); //adds the content type
response = webRequest.GetResponse();
TIA, Ian
information from and I'm trying to get the web service to use a client
certificate. If the remote IIS site is set up to ignore the client
ceritficate then the request works with no problem. If I set the remote IIS
site to accept the client certificate then I get a HTTP 403 forbidden error,
and in the event log I get an event ID 1309 for the web service with the text
"Server cannot clear headers after HTTP headers have been sent. Below is an
extract from my web service code and I can't for the life of me figure what
the problem is:
ServicePointManager.ServerCertificateValidationCallback = new
RemoteCertificateValidationCallback(VerifyServerCertificate);
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(strUri);
webRequest.Credentials = new NetworkCredential(strUserName, strPassword,
strDomain);
this.GetClientCertificate(webRequest); // adds the client certificate to the
request
AddHeadersToRequest(additionalHeaders, webRequest); // adds Range header etc
webRequest.Method = strMethodName;
if (0 != baRequestBody.Length)
{
webRequest.ContentLength = baRequestBody.Length;
Stream requestStream = webRequest.GetRequestStream();
requestStream.Write(baRequestBody, 0, baRequestBody.Length);
requestStream.Close();
}
AddContentTypeToRequest(contentType, webRequest); //adds the content type
response = webRequest.GetResponse();
TIA, Ian