Security :: Using A X509 Certificate In A Web-service

Jun 17, 2010

I have a rather strange situation that I am in.

I have to write a web-service that will (among other things) communicate with another web service. When we communicate with that remote web-service we are required to use a certificate that they provided.

I am having a really hard time trying to find any sample code that does this.

I have found code for installing certs when you want to use a browser to communicate, but none when you are using a web-service to web-service and you are required to HAVE the certificate, not requiring the OTHER end to have the certificate.

So far I cannot even find code to allow me to parse throught the cert store. Samples I found online show up as errors in Visual Studio 2005.

Note: This is running one Windows 2000, designed with Visual Studio 2005, asp.net 2.0

View 1 Replies


Similar Messages:

WCF / ASMX :: Web Service Security Using X509 Certificate

Nov 17, 2010

Am facing problem while consuming a java web service using WCF. below is the web.config and aspx.cs file details

Requirement

Service request and response will be encrypted with certificate. when i run this below code am getting the error "The private key is not present in the X.509 certificate."

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="TestClientCertificate">
<clientCredentials>
<clientCertificate storeLocation="CurrentUser" storeName="My"
findValue="certificatename" x509FindType="FindByIssuerName"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="TestHttpBinding" maxReceivedMessageSize="1048576" maxBufferSize="1048576" transferMode="Buffered">
<security mode="TransportWithMessageCredential">
<!--<transport clientCredentialType="Certificate"/>-->
<message clientCredentialType="Certificate"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="TestHttpPort" address="https://webserviceurl/webservice"
binding="basicHttpBinding" bindingConfiguration="TestHttpBinding"
behaviorConfiguration="TestClientCertificate"
contract="ServiceReference1.webService1">
</endpoint>
</client>
</system.serviceModel>

in page
protected void Page_Load(object sender, EventArgs e)
{
WebServiceClient abc = new WebServiceClient();
BindingElementCollection elements = abc.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().IncludeTimestamp = true;
abc.Endpoint.Binding = new CustomBinding(elements);
WebServiceClientResponse xyz = abc.WebMethod("", "");
}
private static bool customXertificateValidation(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error)
{
return true;
}
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="TestClientCertificate">
<clientCredentials>
<clientCertificate storeLocation="CurrentUser" storeName="My"
findValue="partnerservices" x509FindType="FindByIssuerName"/>
</clientCredentials>
<!--<serviceDebug includeExceptionDetailInFaults="true"/>-->
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="TestHttpBinding" maxReceivedMessageSize="1048576" maxBufferSize="1048576" transferMode="Buffered">
<security mode="TransportWithMessageCredential">
<!--<transport clientCredentialType="Certificate"/>-->
<message clientCredentialType="Certificate"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="TestHttpPort" address="https://webservicespprd.biworldwide.com/partnerservices/services/v1/AccountWebService.biws"
binding="basicHttpBinding" bindingConfiguration="TestHttpBinding"
behaviorConfiguration="TestClientCertificate"
contract="ServiceReference1.AccountWebService">
<!--<identity>
<certificate encodedValue="MIIB5zCCAVCgAwIBAgIQlerVslZ+4p1Of3evhNc3TDANBgkqhkiG9w0BAQQFADAP
MQ0wCwYDVQQDEwRTR0JJMB4XDTEwMTExNjA5MjYyOVoXDTM5MTIzMTIzNTk1OVow
DzENMAsGA1UEAxMEU0dCSTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA5mYW
n4Qp/8uosJ56fXLqygOkTDuYTTX0KECRce7fkeCFH8SpqQeCltNMjFgNRzr+C4rk
6A7GFe6gMiVyogqYgQn/QyZGT5iTXJ4khkAYui/gLX4Cga3tBCoVckja/93bCUOS
G4rS7W86kgG2hV+BfceqmlRISnlaLWxN/Ys6TAsCAwEAAaNEMEIwQAYDVR0BBDkw
N4AQ7veQWUUKR17/SJxFCEHu56ERMA8xDTALBgNVBAMTBFNHQkmCEJXq1bJWfuKd
Tn93r4TXN0wwDQYJKoZIhvcNAQEEBQADgYEAPsTiaYcghQCtBRH8FupLZIzliSHx
h3rsr6mKQT68rA+I9qjs/lsPaN2ebajDb3xzJRmjlrz2+9Gjc9LUGDaHEgxsPHab
Dh/IOgkqyjVAJHufjroKFfkzTJwwB4/uWU2vOKPpqVXfLqRXJ8du25MI7iWcHVfg
oYS1eESNBuPCErQ="/>
</identity>-->
</endpoint>
</client>
</system.serviceModel>

View 7 Replies

Security :: Encrypting With An X509 Certificate.

Mar 14, 2011

I have created an x590 certificate that is in the file :
"C:UsersmartinAppDataRoamingMicrosoftSystemCertificatesMyCertificates"

I am trying to acces the public key to encrypt some plain text.

The system is throwing an "System.ArgumentOutOfRangeException" at the line

Dim certificate As X509Certificate2 = certificateCollection(0)

Can anyone tell me where I am going wrong or tell me another way to access the public key

.................................................
This is the complete code:
Imports System.Security
Imports System.Security.Cryptography.X509Certificates
Imports System.Security.Cryptography.X509Certificates.X509Certificate2
Imports System.Security.Cryptography.Pkcs
Partial Class encryptwithcertificare
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim encoding As UTF8Encoding = New UTF8Encoding
Dim cleartext As String = Textbox1.Text
Dim myStore As X509Store = New X509Store()
myStore.Open(OpenFlags.ReadOnly)
Dim certificateCollection As X509Certificate2Collection = myStore.Certificates.Find(X509FindType.FindBySubjectName, "bobby", True)
Dim certificate As X509Certificate2 = certificateCollection(0)
Dim code() As Byte = EncryptwithCertificate(cleartext, certificate)
Label1.Text = Convert.ToBase64String(code)
End Sub
Shared Function EncryptwithCertificate(ByVal cleartext As Byte, ByVal certificate As X509Certificate2) As Byte()
Dim encoding As UTF8Encoding = New UTF8Encoding
Dim cleartextsbyte() As Byte = encoding.GetBytes(cleartext)
Dim contentinfo As ContentInfo = New ContentInfo(cleartextsbyte)
Dim envelopedCms As EnvelopedCms = New EnvelopedCms(contentinfo)
Dim recipient As CmsRecipient = New CmsRecipient(certificate)
envelopedCms.Encrypt(recipient)
Return envelopedCms.Encode()
End Function
End Class

View 3 Replies

Security :: Add CSP Information To X509 Certificate Programmatically

Mar 3, 2010

I'm working on a project for a large company that wants to create a crypto toolbox for cross-platform signing and encrypting and am constantly running into problems concerning the cryptographic abilities in the .Net framework. The blazing inferno that I need to put out this time is that SignedCms and EnvelopedCms don't seem to work with a Cryptographic Service Provider that doesn't store the private-key on the Windows machine. I'm working with a network HSM and certicates that have only a public key, that is, no private-key and no information in the store as to where that private-key resides or how you can access it (a RSA public/private key pair is created on the machine, using the HSM supplier's CSP, and a certificate signing request is generated and used to create a public-key certificate signed by the CA). Theoretically the private key gets picked up from the HSM (referenced actually) using the CspParameters given when instantiating the class, which specifies the CSP provided by the HSM supplier. Unfortunately, up to now this only works with CAPI, where can associate the cryptographic service provider with the signing certificate (usign CertSetCertificateContextProperty with CERT_KEY_PROV_HANDLE_PROP_ID). (We're using CAPI for PKCS#7 signing because the .Net framework only supports signatures up to SHA1 and we have a minimum of SHA256). Surprisingly enough CmsSigner accepts a CSP in it's constructor but it cannot get the key, it throws an exception during instantiation from method CreateDummyCertificate for some reason (with the message "Process completed." no less!??). I use the following CspParameters:

[Code]....

CmsSigner cmsSigner = new CmsSigner(cspParams);

This process works great with certificates and key pairs created by MakeCert. With MakeCert you can associate the CSP information with the Certificate upon creation (-sk, -sp, -sy). The private key still resides in the HSM but specifying the provider during the creation of the certificate seems to have persisted the CSP information somewhere, somehow. Exactly how that's done I don't know, but if could do that, my problem would be solved.

View 2 Replies

Security :: X509 - Client Certificate Infrastructure

Sep 9, 2010

I dont have a lot of background with SSL and X509 configuration and support with my Asp.Net application, so I was wondering if someone can explain or point me in the right direction to MSDN or any other article or posting explaining if it's possible to do what I am looking to support in my environment.

I have IIS 6.0 with SSL (Verisign cert) as well as "Require client certificates" working against a local installation of Microsoft Certificate Services, https://<domain>/certsrv, where users can request and install client certs (both xp clients for basic
mode, and Vista/7 for advance mode).

Here's what I am up against:

I have a segment of users coming from a virtualized server environment where this environment does not store personal settings for more than 48 hours. It's not an internet cafe, but rather an actual business where their IT staff uses server images to reimage each virtual server in the farm every 48hrs. Thus losing all users data in the "Current Users" Certificate Stores.

The IT staff give users a network folder share to store any personal items (docs, spreadsheets, links, etc.). The servers consist of Windows Server 2003, and will be migrating to Windows Server 2008 in the next 6-9 months.

These users have rights in Internet Explorer to navigate to my certsrv site and use activex to to request and install certificates then clode and reopen the broser to navigate and render the asp.net app.


Problem:

It's a pain to ask the users to request and have issued a client certificate every 48 hours.

The IT staff of this company has asked if I can create some sort of certificate that they can load in the "local computer" certificate store, NOT the "Current User" store, that will be made part of their base image for all their servers, and that this certificate is then used to properly authenticate all users on these servers to my IIS with "require client certificates" selected.

Question:

Is this possible, and if so what can I do on my side to create the proper certificate to give to the IT staff at this business to put into their servers "local computer" certificate store? I assume either under the Personal->Certificates store, or under the "Trusted Root Certification Authorities"->Certificates store. Thus allowing any user of these servers in their thin client virtual environment to open I.E., navigate to my site and select a certificate from the "Choose a digital certificate" popup that allows them to render my Asp.Net application, or avoids this popup altogether.

If this is the wrong forum to post in, please advise and I will move. Probably due to vernacular on my part, I have been unable to find any resources on here, MSDN or Bing to help me solve this problem.

View 1 Replies

Security :: View A Current Users X509 Certificate Store

Mar 15, 2011

Quick question: is it possible to retrive a users certificate store i.e. list all of the client's Personal Certificates?

Just to be clear, I am talking about the certificates installed on the clients machine, not the servers. I have managed to list the server's certificates, but so far have been unsuccesful with the above.

View 2 Replies

C# - How Do I Find The Subjectdistinguishedname Of A X509 Certificate

Jul 12, 2010

I am trying to use the X509FindType.FindBySubjectDistinguishedName option and I am not sure where to find the value for the findValue property in my config.

http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509findtype.aspx

View 1 Replies

C# - Can't Connect To HTTPS Using X509 Client Certificate

May 24, 2010

I'm new to cryptography and I'm a bit stuck:

I'm trying to connect (from my development environment) to a web service using HTTPS. The web service requires a client certificate - which I think I've installed correctly.

They have supplied me with a .PFX file. In Windows 7, I double clicked the file to install it into my Current User - Personal certificate store.

I then exported a X509 Base-64 encoded .cer file from the certificate entry in the store. It didn't have a private key associate with it.

Then, in my app, I'm attempting to connect to the service like this:

var certificate = X509Certificate.CreateFromCertFile("xyz.cer"));
var serviceUrl = "https://xyz";
var request = (HttpWebRequest) WebRequest.Create(serviceUrl);
request.ClientCertificates.Add(certificate);
request.Method = WebRequestMethods.Http.Post;
request.ContentType = "application/x-www-form-urlencoded";

I get a 502 Connection failed when I connect.

Is there anything you can see wrong with this method? Our production environment seems to work with a similar configuration, but it's running Windows Server 2003.

View 2 Replies

Security :: WCF Service Hosting With Certificate

Dec 14, 2010

Keyset does not existDescription:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Security.Cryptography.CryptographicException: Keyset does not existSource Error:

[Code]...

View 1 Replies

Security :: Authenticate X.509 Client Certificate In Web Service?

Jul 26, 2010

I need to send a X.509 client certificate to a web service in byte array (not attached to request). Besides the certificate, the caller will also send data and signed data. From the web service I can verify if the signature is ok but I don't know what is required to verify that the certificate is ok. I have the client certificate issuer CA trusted in Server (where the web service runs).

More specifically, how can I verify if a X.509 certificate itself is valid? I need to do it in web service not from IIS.

View 4 Replies

Security :: Passing Certificate To External Web Service?

Apr 14, 2010

I'm calling an external Web service that requires a certificate to be passed. This works perfectly fine for a stand-alone Windows Forms application, but when I attempt to do the exact same thing through an ASP.NET Web Application, it throws the following error:

"No connection could be made because the target machine actively refused it"

I found this MS article that describes what appears to be the exact issue I'm having, but it only applies to .NET 1.0:

[URL]

I'm using .NET 3.5, so surely it must be fixed by now!

I've attempted to change permissions on the certificate and fooled around with the app pool identity, but nothing seems to work.

View 2 Replies

Security :: Share Certificate Between Website And Self-hosted Wcf Service

Feb 12, 2010

If I buy a CA certificate for the one site on the webserver, can I use the same certificate on a self-hosted wcf service.

The wcf service will use wsHttpBinding with username/password authentication.

View 2 Replies

Security :: Decrypting Using X509 Certificates?

Mar 16, 2011

I am trying to decrypt using an X509 certificate private key. I am using the following function:

[Code]....

View 3 Replies

Security :: Request A Client's X509 Cert W/o Windows Auth

Mar 15, 2010

Is it possible to request an X509 certificate from a client without configuring the application to use Windows Authentication? The purpose would be to press an asp.net button and "digitially sign" a web-form's contents. I do not need any login information, just the X509 cert.

View 1 Replies

WCF / ASMX :: Receive Client Certificate In Web Service?

Oct 15, 2010

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

Client

[Code]....

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

The client connects to the server with HTTPS.

Server:

[Code]....

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.

View 1 Replies

Security :: How To Implement Certificate Security In Production Environment

Jun 15, 2010

I have searched and could not find any article related to "How to implement Certificate Security in
production environment".

I could able to Create sample certificates for client and Server on my local machine and was able to authenticate my client app with the certificates . These certificates are test certificates.

How do I do this in Production. We have a domain certificate from GoDaddy which resides on the server. How do I create a Client Certificate off of that.

View 2 Replies

SSL Certificate Type Required For PayPal HTTPS Web Service (Payments Pro SOAP / NVP)

Feb 25, 2011

We set up a paypal gateway on our site using paypal NVP API: Our IIS web server is set up for SSL, though I just created a cert on the locally machine. When we load HTTPS the browser gives a warning about security before the page will load. I know a local cert won't cut it for SSL, so I think we need a verisign cert? [URL] Is this correct? How can I know that the cert I am getting will get along with paypal and elimante any security warnings for the user.

View 1 Replies

Security :: When To Use An Ssl Certificate

Jan 23, 2011

If I'm taking a password on a page, should that page be served via https and exactly how dangerous is it not to? I've tried googling this but every guide just says that ssl certificates "stop hackers seeing sensative data" with no real description of how they would do this or exactly how vulnerable your site is as a result of not having ssl.Could someone summarize how easy it is for someone to steal passwords on non-https pages? Should i even be considering doing a login page without one?

View 4 Replies

Security :: How To Use Microsoft Certificate Services

Apr 10, 2010

I need to know abt Microsoft Certificate Services ...can u guys xplain in details ....I find microsoft article regarding this ....Stil cnt able to do ..Am a new bee in this kind of stuff ....

View 2 Replies

Security :: Add Certificate For NetworkService - Win7?

Jun 18, 2010

I need to add a cert. for the NetworkService account as this is what Identity of my App pool is set to, but I'm not sure how to go about doing that. Here's the steps, I take: Bring up the run command and submit "mmc"When the Management console appears I click on File > Add/Remove snap-in.Select Certificates and click AddSelect Service Account, click Next twice Then I'm presented with a bunch of Service Accounts. The ones that kind of resemble what I'm looking for are: Network Access Protection AgentNetwork ConnectionsNetwork List ServiceNetwork Location AwarenessNetwork Store Interface Service Out of the choices above, Network List Service would be my best guess.

View 1 Replies

Security :: How To Get Certificate Information Of A Website

Apr 8, 2010

I want to get the certificate information of a website. I means that i've a textbox on a page. When i enter a url in that textbox and press the button. The certificate information of that website should be returned.

Say, i've entered the [URL], Then it should return the Certificate authority, Validation period etc.

View 1 Replies

Security :: Get Remote SSL Certificate Information?

Nov 27, 2010

I am looking to get the data from any given domain names SSL certificate. For example I want to put in any website address e.g. "www.asp.net" and my code would firstly check if an SSL certificate exists. If it does then I want it to pull out the Issuer, Subject, Valid From and Valid Until etc. The intention is to create an SSL certificate checker similar to this: [URL]

How can I do this ASP.net???? - I have looked up loads of different things such as RequestCertificateValidationCallback and ClientCertificates etc.

would I create a HTTPWebRequest and then somehow request the client certificate and specific elements that way?

View 6 Replies

Security :: SSL - Programitically Locate SSL Certificate?

Mar 11, 2010

This is my first time stepping into the wonderful world of SSL. I am working on a project which forces the HTTPS protocol/ Url Scheme for certain parts of the site. I mananged to get that working fine.

<br/>

There is another part of the project where I pull binary image data from a database, and then write/render the image onto the browser window. <b>I found that since I converted the site to SSL, the rendering no longer works</b>. I am now working under the believe that I must open my a System.Net.Security.SSLStream in order to stream the bytes to the Response.

<br/>I'm at the point where I am writing the SSLStream, but there is a major roadblock. I don't know how to
programmatically locate my X509Certificate so that I can authenticate the SSLStream. To make this problem a little more challenging, I am working with a somewhat-unpopular shared hosting provider, who does not give me access to the certificate name - which probably is not a big deal. I am guessing I'm just going about this problem the wrong way. <br/>

View 2 Replies

Security :: Invalid HTTPS Certificate?

Dec 23, 2010

Do you know any web site with an invalid https certificate, so I can test if my browser detects it?

View 1 Replies

Security :: Possible To Apply For Certificate For Ip Address

Sep 21, 2010

we have one e-commece website which combine one ip address and 4 domains, I want apply for one ssl certificate bind ip for this site, is it possible to be used for 4 domains? is it possible to apply for certificate for ip address?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved