Calling Webservice over SSL w/Client Certificate from aspx

S

Sunil

Hello Gurus,
Trying to consume a webservice through aspx page over SSL with Client
Certificate and getting below error.

System.Net.WebException: The request failed with HTTP status 403: Access
Forbidden. at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
Message message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)

Am able to consume the same webservice using console application. Am I doing
something wrong.
Here is the sample code which is working fine using console application
---------------------------------
Dim ws As New ws.getData()
Dim nFormat As Integer = 0
ws.Url = "https://securesite/webservice.asmx"
Dim cert As X509Certificate =
X509Certificate.CreateFromCertFile("c:\sendCert.cer")
ws.ClientCertificates.Add(cert)
ws.GetNumber("string", nFormat)
 
J

Jan Tielens

Hi

Does your ASP.NET account (or the user account that asp.net uses) has access
to the c:\sendCert.cer file? Probably you've got to give this account
explicit rights to this file/folder.
 
S

Sunil

Jan,

Even tried to give explicit permission for asp.net to access this file. but
still gives the error. This is really bugging me. please let me know
anything else need to be done. Thanks in advance for your time. I am using
<identity impersonate="true" /> in the web.config file.

Is there any way I can debug this problem or to know why is it giving error.


S


Jan Tielens said:
Hi

Does your ASP.NET account (or the user account that asp.net uses) has access
to the c:\sendCert.cer file? Probably you've got to give this account
explicit rights to this file/folder.

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
Sunil said:
Hello Gurus,
Trying to consume a webservice through aspx page over SSL with Client
Certificate and getting below error.

System.Net.WebException: The request failed with HTTP status 403: Access
Forbidden. at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
Message message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)

Am able to consume the same webservice using console application. Am I doing
something wrong.
Here is the sample code which is working fine using console application
---------------------------------
Dim ws As New ws.getData()
Dim nFormat As Integer = 0
ws.Url = "https://securesite/webservice.asmx"
Dim cert As X509Certificate =
X509Certificate.CreateFromCertFile("c:\sendCert.cer")
ws.ClientCertificates.Add(cert)
ws.GetNumber("string", nFormat)
-----------

Please help. Thanks in advance

S
 
J

Jan Tielens

You can set a breakpoint in your webservice, start it in debug mode and try
to connect to the webservice from your client application. You should hit
the breakpoint so you can step through the code.

Let me know if you could step through the code, if not we should search
further.

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
Sunil said:
Jan,

Even tried to give explicit permission for asp.net to access this file. but
still gives the error. This is really bugging me. please let me know
anything else need to be done. Thanks in advance for your time. I am using
<identity impersonate="true" /> in the web.config file.

Is there any way I can debug this problem or to know why is it giving error.


S


Jan Tielens said:
Hi

Does your ASP.NET account (or the user account that asp.net uses) has access
to the c:\sendCert.cer file? Probably you've got to give this account
explicit rights to this file/folder.

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
Message message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)

Am able to consume the same webservice using console application. Am I doing
something wrong.
Here is the sample code which is working fine using console application
---------------------------------
Dim ws As New ws.getData()
Dim nFormat As Integer = 0
ws.Url = "https://securesite/webservice.asmx"
Dim cert As X509Certificate =
X509Certificate.CreateFromCertFile("c:\sendCert.cer")
ws.ClientCertificates.Add(cert)
ws.GetNumber("string", nFormat)
-----------

Please help. Thanks in advance

S
 
S

Sunil

Hi Jan,
I am able to debug the code. Let me know what do you want me to do next.
Thanks for you time.

Thanks,
S


Jan Tielens said:
You can set a breakpoint in your webservice, start it in debug mode and try
to connect to the webservice from your client application. You should hit
the breakpoint so you can step through the code.

Let me know if you could step through the code, if not we should search
further.

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
Sunil said:
Jan,

Even tried to give explicit permission for asp.net to access this file. but
still gives the error. This is really bugging me. please let me know
anything else need to be done. Thanks in advance for your time. I am using
<identity impersonate="true" /> in the web.config file.

Is there any way I can debug this problem or to know why is it giving error.


S
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
Message message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)

Am able to consume the same webservice using console application. Am I
doing
something wrong.
Here is the sample code which is working fine using console application
---------------------------------
Dim ws As New ws.getData()
Dim nFormat As Integer = 0
ws.Url = "https://securesite/webservice.asmx"
Dim cert As X509Certificate =
X509Certificate.CreateFromCertFile("c:\sendCert.cer")
ws.ClientCertificates.Add(cert)
ws.GetNumber("string", nFormat)
-----------

Please help. Thanks in advance

S
 
J

Jan Tielens

Can you check which line throws the exception?

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
Sunil said:
Hi Jan,
I am able to debug the code. Let me know what do you want me to do next.
Thanks for you time.

Thanks,
S


Jan Tielens said:
You can set a breakpoint in your webservice, start it in debug mode and try
to connect to the webservice from your client application. You should hit
the breakpoint so you can step through the code.

Let me know if you could step through the code, if not we should search
further.

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
file.
but
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
Message message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)

Am able to consume the same webservice using console application.
Am
 
S

Sunil

Giving me this error System.Net.WebException: The request failed with HTTP
status 403: Access Forbidden.
when calling webservice method
ws.GetNumber("string", nFormat)

There is no error
Dim ws As New ws.getData()
Dim nFormat As Integer = 0
ws.Url = "https://securesite/webservice.asmx"
Dim cert As X509Certificate =
X509Certificate.CreateFromCertFile("c:\sendCert.cer")
ws.ClientCertificates.Add(cert)
ws.GetNumber("string", nFormat) -- @@ ------Error occurs here
 
J

Jan Tielens

You are probably debugging your client application, you should try if you
can hit a breakpoint in your webservice:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top