.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

C# ASP .NET 3.5 IIS Web Service with Client Certificate

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :.NET Framework
 

Hi,

I'm creating a Web application to consume a third party Web Service. The third party provide me a Security Certificate and I can get their wsdl successfuly in the browser by using it.

Before I start, I created a Unit Test to consume the web service with the certificate provided, and it works fine.

I've also create a Console application to consume the web service (same code), and again it works fine.

The problem is, I created a Web application (ASP .NET 2.0 in IIS) but it fails. The thrid party said I didn't add the client certificate in the Web service call. But I'm using the same code as the Unit Test and the Console application I developed.

Background: The web application has impersonate="true" and we are using Integrated Windows Authentication. We have a Web proxy in our company and we need go go through it to Internet.

The code I use is below, I believe the code is fine as it works in Unit Test and in the Console app.

======================================================================================

this.BuySideService = new FXBuySideServiceV1();

// preserve cookies for auth info (SMSESSION)
this.BuySideService.CookieContainer = new System.Net.CookieContainer();

// basic authentication
this.BuySideService.Credentials = new System.Net.NetworkCredential(this.LoginUsername,


View Complete Post


More Related Resource Links

Receive Client Certificate in Web Service

  

I'm trying to receive a Client Certificate in a Web Service and having some problems.

Client      

Dim cert As X509Certificate = X509Certificate.CreateFromCertFile("C:\cert.cer")
_ws.ClientCertificates.Add(cert)
Dim hw As String = _ws.HelloWorld

The certificate seems to be correclty loading and added to the client.

The client connects to the server with HTTPS.

Server:

 <WebMethod()> _
    Public Function HelloWorld() As String
        Dim cert As HttpClientCertificate = Me.Context.Request.ClientCertificate
        Return "Hello World"
    End Function

cert.IsPresent is false and all certificate fields are empty.

IIS is configured to Accept Client Certificates.

Reproduced in two environments:

- Windows 7 x64, IIS 7, VS 2008, .NET 3.5

- XP x86, IIS 5, VS 2008, .NET 3.5

Always in the Web Service the Client Certificate is not proesent. I haven't been able to find any other configuration I should do. Can anyone help?

Thanks

Steve


WCF Service to WSE Client - Certificate authentication over SSL

  
I am trying to access a WCF service with a WSE 3.0 client over SSL using certificate authentication.  I can do it over an unsecured channel using a customBinding on the service side using the MutualCertificate authentication mode and the turnkey policy assertion mutualCertificate11Security on the client side.  This breaks when I move it to a production environment accessible only by SSL and either (1) change nothing in the server config file--connection gets refused because it is not https--or by (2) changing the server custom binding to CertificateOverTransport--client errors with this:  System.InvalidOperationException: Security requirements are not satisfied because the security header is not present in the incoming message.

My question is simply, how do I access a WCF service over SSL using certificate authentication?

Thanks,
Chris



c# .NET 3.5 Web Service with Client Certificate

  

Hi,

I'm creating a Web application to consume a third party Web service. The third party has provided me a Security Certificate and I can use it to see their WSDL in Browser successfully.

I've created a Unit Test to consume the web service with the client certificate and it works fine.

I've also create a Console application to consume the web service, and again it works fine.

The problem is, I created a Web application (ASP .NET in IIS) to consume the web service, and it fails. The party said I didn't send the Client Certificate in the Web Service call. But the code I use is the same as the one running in the Unit Test and Console application.

Background: The Web Application has impersonate="true" and we are using Integrated Windows Authentication. Also we have a Web Proxy in our company to go out to internet.

Below is the code I'm using. I believe the code is fine as it works in some cases except in ASP .NET (IIS). 

========================================================================================

this.BuySideService = new FXBuySideServiceV1();

// preserve cookies for auth info (SMSESSION)
this.BuySideService.CookieContainer = new System.Net.CookieContainer();

// basic authentication
this.BuySideService.Credentials = new System.

Problem to obtain client IP on web service

  

Friends,

I'm having problems to obtain the client IP on web service. Here's my scenario:

One server with Windows 2003, hosting the web service using .Net Framework 2.0, with IP 10.0.2.50 and host name ServerTransaction.
Other server with Windows 2003, hosting a web application using .Net Framework 2.0, that consuming the web service on  ServerTransaction, with IP 10.0.2.51 and host name ServerApplication.
Many other computers on the local network (IPs: 10.0.2.80, 10.0.2.81, 10.0.2.82, ...) acessing the web application on ServerApplication.

On the code of the web service I've tried to use HttpContext.Current.Request.UserHostAddress or HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") or HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FORR"), but always I can only get the IP of ServerApplication (10.0.2.51).

Any idea or tip?


Thanks and sorry for my bad english.


Smart Client: Building Distributed Apps with NHibernate and Rhino Service Bus, Part 2

  

Smart client applications are responsive and promote interactivity with the user. In this article, we continue building a smart client application using NHibernate for data access and Rhino Service Bus for reliable communication with the server.

Oren Eini

MSDN Magazine August 2010


Smart Client: Building Distributed Apps with NHibernate and Rhino Service Bus

  

Smart client applications are responsive and promote interactivity with the user. In this article, we start the processes of planning and building a smart client application using NHibernate for data access and Rhino Service Bus for reliable communication with the server.

Oren Eini

MSDN Magazine July 2010


Extreme ASP.NET: Client-Side Web Service Calls with AJAX Extensions

  

Microsoft AJAX Library and the ASP.NET 2.0 AJAX Extensions provide a number of compelling features ranging from client-side data binding, to DHTML animations and behaviors. Learn all about them here.

Fritz Onion

MSDN Magazine January 2007


Looking for a simple Service and Console Client REST sample implementing BASIC authentication

  

Does anyone know of a C# code sample demonstrating WCF REST services and console test client with OperationContracts (GET and POST) implementing mutiple paramaters using BASIC authentication? Also, perhaps, using Fiddler as a test client as well? I have searched high and low for something like this, but have not had any success.


sslstream client certificate validation error

  
Hi,I have taken server and client program from MSDN2 for sslstream. in that code client certifiacte authetication is made false  i want to enable that and do the code i have done some modification to the code but is giving error "RemoteCertificateNotAvailable" and i think that its not getting the client certificate at server side.So please can any one help me to do client server program using sslstream in which client certificate also needs to be validated.I am attaching my modified code of MSDN2Server sideusing System;using System.Collections;using System.Net;using System.Net.Sockets;using System.Net.Security;using System.Security.Authentication;using System.Text;using System.Security.Cryptography.X509Certificates;using System.IO;namespace Examples.System.Net{    public sealed class SslTcpServer     {        static X509Certificate serverCertificate = null;        // The certificate parameter specifies the name of the file         // containing the machine certificate.        // The following method is invoked by the RemoteCertificateValidationDelegate.        public static bool ValidateClientCertificate(              object sender,              X509Certificate certificate,              X509Chain chain,              SslPolicyErrors sslPolicyErrors)        {            SslPolicyErrors errors = sslPolicyErrors;            if (errors != SslPolicyErrors.None)            {

WCF client to WSE 3.0 service

  
Dear all,   I try to create WCF client to WSE 3.0 service. I have already working WSE3.0 client to the same service. Here is it's configurations:   <microsoft.web.services3> <security> <timeToleranceInSeconds value="10000"/> <x509 allowTestRoot="true" verifyTrust="true" storeLocation="CurrentUser"/> <binarySecurityTokenManager> <add valueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"> <keyAlgorithm name="RSA15"/> </add> </binarySecurityTokenManager> </security> </microsoft.web.services3>   And the policy for the service client created in such a way:   MutualCertificate10Assertion assertion = new MutualCertificate10Assertion() { EstablishSecurityContext = false, RenewExpiredSecurityContext = true, RequireSignatureConfirmation = false, MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt, RequireDerivedKeys = false, TtlInSeconds = 300 }; assertion.ClientX509TokenProvider = new X509TokenProvider(StoreLocation.LocalMachine, StoreName.My, "ClientCerfiticateName", X509FindType.FindBySubjectName); assertion.ServiceX509TokenProvider = new X509TokenProvider(StoreLocatio

WCF client to WSE 3.0 service

  
Dear all,   I try to create WCF client to WSE 3.0 service. I have already working WSE3.0 client to the same service. Here is it's configurations:   <microsoft.web.services3> <security> <timeToleranceInSeconds value="10000"/> <x509 allowTestRoot="true" verifyTrust="true" storeLocation="CurrentUser"/> <binarySecurityTokenManager> <add valueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"> <keyAlgorithm name="RSA15"/> </add> </binarySecurityTokenManager> </security> </microsoft.web.services3>   And the policy for the service client created in such a way:   MutualCertificate10Assertion assertion = new MutualCertificate10Assertion() { EstablishSecurityContext = false, RenewExpiredSecurityContext = true, RequireSignatureConfirmation = false, MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt, RequireDerivedKeys = false, TtlInSeconds = 300 }; assertion.ClientX509TokenProvider = new X509TokenProvider(StoreLocation.LocalMachine, StoreName.My, "ClientCerfiticateName", X509FindType.FindBySubjectName); assertion.ServiceX509TokenProvider = new X509TokenProvider(StoreLocatio

Error in consuming web service using WCF client

  
Hi, I have consumed an external webservice in my client application using WCF. And every thing works great in my Dev box(XP with IIS5.1) But when the same application is moved to Prod server(Win Server 2003 with IIS6.0) it fails. Below is the exception caught: There was no endpoint listening at http://MyExternalWebServiceUrlWithSessionId could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. And the InnerException is: Unable to connect to the remote server My Config file has the below settings:<system.serviceModel> <bindings> <basicHttpBinding> <binding name="Default_Binding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCoun

connect client certificate to an account in a membership database

  
Hello I have created a web service that authenticates with username and password, works fine.Basically this one, http://msdn.microsoft.com/en-us/library/ff649647.aspxNow I also want to connect to this web service using client certificates, works finehttp://msdn.microsoft.com/en-us/library/cc948997.aspx But I would like to when authenticated via client certificates, connect that certificate to a user in the membership database.So that I can use Roles.IsUserInRole(...) and such.I thought that, well if I implement a Custom certificate Validatorhttp://msdn.microsoft.com/en-us/library/ms733806.aspxthen I could check for example subject and map that against a created username in the membership database.But in the class X509CertificateValidatorpublic override void Validate(X509Certificate2 certificate)I don't have the same ability as when the user is authenticatedlike  void OnAuthenticateRequest(object source, EventArgs eventArgs)HttpApplication app = (HttpApplication)source;Basically how can I do this app.Context.User = new GenericPrincipal(new GenericIdentity(username, "Membership Provider"),roles);withinpublic override void Validate(X509Certificate2 certificate)and if that is not possible, can this be solved differently?Bottom line, how do I connect a client certificate to a user account in the membership database. Is there a MSDN article

.NET Client and Java Web Service Interoperability

  
I have a .net client that consumes an operation on a java based web service that appears to work accept for an issue with passing Boolean values back to the service in the soap message. Any member of the complex type that are defined as Boolean in the service contract will not be present in the soap message generated from the client even though they are set in the code. Sample Client Code: UpdateChecklistItemStatusPortTypeClient     proxy = new UpdateChecklistItemStatusPortTypeClient();     updateChecklistItemStatusReq request = new updateChecklistItemStatusReq(); request.ouid =   "P000122112"; request.applicationId =   "00000032"; request.adminFunction =   "ADMA"; request.checklistItemTypeCode =   "UHSTRN"; request.ceebCode =   "052046"; request.transcriptTerm =   "FINAL"; request.transcriptScores =   true;     updateChecklistItemStatusRsp response = new updateChecklistItemStatusRsp(); response = proxy.UpdateChecklistItemStatusOp(request); Client Soap Message Generated: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">   

Getting client information from X.509 certificate in C# code

  
I have a WCF service which accepts X.509 certificate signed incoming messages. As per my understanding the client will send the message with signature encrypted using his private key and web services will decrypt the signature with client's public key. This ensures that the sender of the message is holder of the private key and that he is certified by the server trusted CA as "He is what he claims to be". It's being a highly secure application I need to give access to only certain clients regardless of whether they are trusted or not. (This is to take care of good turned bad scenario :-)) How do I achieve this? Is there any way to get the client information as subject name etc from his certificate in C# code? Is there any example of this usage? Thanks in advance,Jeet.    

Async Web Service behavior on client disconnect

  
Hi all, I was wondering what is the best way to detect client disconnect in the middle of an async web service call. I'm asusming that if a client disconnects while the server is still processing the async web method call, an exception will be thrown. First, I wonder if someone can confirm that this is the right assumption. If that's the case, then I was wondering where should I set up the SEH block to catch this exception. My gut tells me to set up the SEH block in side the delegate funciton, but I might be wrong. Also, what kind of an exception would I be getting if the client disconnects? Finally, if the SEH is set up in the delegate, what happens if a client disconnects in the tiny window before or after the delegate gets called? If someone can shed some light here I'd really appreciate it! Thanks, - K.  

WCF Service client problem.

  
Hi,I have hosted a wcf service over IIS with Windows Authentication. All the users are able to access the WCF service Url from their machine. The problem is that some of the user are able to consume the webservice method while few of them when try to consume the service ,the error is thrown connection - reset error.I have tried to go through the IIS log also but it did'nt helped.Can any one help me regarding this. What settings I need to check/change to solve the proble.Thanks,AKB
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend