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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

RSACryptoServiceProvider + smart card with X509 certificate = Bad Key.

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :.NET Framework
Hello! I'm trying the interop with Java. The task: create  SHA1withRSA signature of the document hash with .NET CLR. The singer key is an X509 certificate from external CA, and this signer certificate is on the smart card. 1. First solution: the .NET CLR SignedCms class passes the document hash to the Windows CryptoApi (and to the smart card), and the result is a PKCS#7 message with the signature. This solution works well with smart card, but the requirement is only the "SHA1withRSA" signature of document hash, the PKCS#7  message will be created at Java side. 2. Second attempt, create only "SHA1withRSA" signature:             // choosing certificate from smart card             X509Certificate2 card = GetCertificate();             // this fails when certificate is on the smart card:             RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)card.PrivateKey;             // only the signed hash needed             byte[] signedHashValue1 = rsa.SignData(documentHash, new SHA1Managed()); The problem: the car

View Complete Post

More Related Resource Links

Smart Storage: Protect Your Data Via Managed Code And The Windows Vista Smart Card APIs


Smart cards are a compelling alternative to the reliance on passwords, which are the weakest link in authentication systems. Get the Windows smart card programming basics here.

Dan Griffin

MSDN Magazine November 2006

WCF with wsHttpBinding and x509 Certificate - can I use VB/C# to connect with PHP?

We connect to a web service hosted by another company.  We send a customer's basic info to the service, and replies with rates/prices for that customer. I am a PHP guy -- started out playing with basic HTML, then delved into PHP about 8 years ago, and my entire web app is PHP with javascrtipt/ajax mixed in as needed.  I'm a learn-as-I-go guy. For the last two years, the service has been an aspx web service, which was easy -- just connect with PHP's SoapClient.  Now, the company hosting the service has changed it to WCF, and the binding is wsHttpBinding, and authentication is done via x509 certification. I've determined that PHP's SoapClient can't handle wsHttpBinding.  So my first roadblack - how the heck do I connect to this service?  I went as far as to install MS Visual Web Developer 2010 Express, and then I used svcutil.exe to create .config and .cs files for the service.  But understand, I've never written anything in C# or VB.  I've done a few little VBScripts in the past, and I can handle javascript... but I'm looking at these .config and .cs files and thinking, now what the heck do I do with these?? Basically, I just want to connect to this service using PHP and javascript.  But since it seems that's impossible (correct?), is there a way I can invoke a VB/C# operation from within my PHP script?  For ins

x509 - Client Certificate infrastructure for Asp.Net question

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

How to setup WCF with wsHttpBinding, Transport Security with x509 certificate behind a load balancer


I'm having a difficult time setting up this WCF Service with wsHttpBinding, Transport Security, x509 and, the key part, the Load Balancer (F5). This all works without a problem in our Dev environment but as soon as I put it behind the F5 it fails giving me this message:

System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority 'servicechannelcert'. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

Is there any additional setup I need to do in IIS or the Load Balancer to handle these requests?

configuration files:

<binding name="wsHttpTransport">
 <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
  maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
 <security mode="Transport&

DllImport and smart card


Hello, i have a problem with a dll.

the dll is casmcard.dll, it interface to the ez100 card reader. i'm using a sle4442 smartcard.
The manufactor gave me a simple vb project that call some function from a static class (CasAPI). It wrap the functions using the dllimport.

I am working on a c# program, so i included the project, to use the CasAPI functions. It works, since i have to change the code of a card (SLE4442_Update_Security_Memory()). The point is that it works just in the vb project, and when i call it from my project it return an error code (SCARD_E_NO_MEMORY that means "Not enough memory available to complete this command").

The vb declaration is 

Public Declare Function SLE4442_Update_Security_Memory Lib "casmcard.dll" (ByVal hCard As Integer, ByRef SendBuffer As Byte, ByVal StartAddr As Integer, ByVal SendBufferLength As Integer) As Integer

and i call it as this

response = CasAPI.SLE4442_Update_Security_Memory(mSCardContext, ref code[0], 1, 3);

code is a 4 byte array 

in vb it is called like this:

Result = SLE4442_Update_Security_Memory(CardHandle, Data(0), 1, 3)


There are many other functions that use the reference of the first element of the array to fill it, and i verified that they all works, so it shouldn't caused by the array.

using a x509 certificate to sign XML using SignedXml class


Hi All,

I am trying to sign an XML file. The code is basically exactly the same as the MSDN sample: http://msdn.microsoft.com/en-us/library/ms229745.aspx

I set the XmlResolver to null:

var settings = new XmlReaderSettings()
          ValidationType = ValidationType.None,
          ProhibitDtd = false,
          IgnoreWhitespace = true,
          XmlResolver = null

This exception is thrown when i call: signedXml.ComputeSignature();

when I do, I receive the following exception:

-  $exception {"An error has occurred while opening external DTD 'http://www.apple.com/DTDs/PropertyList-1.0.dtd': Request for the permi

Web service security using X509 certificate


Dear All,

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


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."

        <behavior name="TestClientCertificate">
            <clientCertificate storeLocation="CurrentUser" storeName="My"
                findValue="certificatename" x509FindType="FindByIssuerName"/>

Cannot upgrade to Win 64 using smart card toolkit


I have an older C# application that has been working fine, and it is using the SCWAPI.DLL and the WINSCARD.DLL.  I am upgrading the application that is using a driver for a device, and when it is run on 64 bit version of Windows 7, it needs to be compiled in X64 to work with this other driver.  When I do this, I can't find a 64 bit version of the SCWAPI.DLL, but there is a WINSCARD.DLL. 

Is there a replacement for the older smart card toolkit that will work on x64, or a 64 bit version of SCWAPI?


How to create a windows mobile (Smart Device) .Cab installer

A Cab file is the default setup format for Windows CE and Windows Mobile devices (similar to windows .msi files). You probably already have installed several application using .cab files, and are familiar with the concept. One point which is often unknown is that .cab files are processed by wceloader.exe, and it can only install one .cab file at a time. That means we cannot have nested .cab files. It doesn't mean we cannot have .cab files contained by another .cab, but the contained .cab files will not be installed during the installation of the container .cab. We should install it manually after the container .cab file installation has been completed.

There are two ways to create a cabinet (.Cab) file. The traditional one, and the friendly VS Smart Device Cab project which doesn't require additional coding, but which also relies on the traditional one at low-level.

no intellisense, smart tag, extender wizard etc


Development Environment:  VS 2008 Pro, IIS 6, asp.net 2.x, sql 2005 server

Installed the version of AJAX Toolkit and Library for the .net 2.0 compatibility (as IIS is still using 2.x)

The problem is as that within the vs 2008 pro, when I select for example a button control...there should be an additional pop-up intellisense indicating...add extender.

to compound this, within the extender control ... the TargetControlID -- should be a drop-down list, indicating which controls are compatible with the extender ... there is no drop-down list.

even if I manually type the control to associate the extender with, this has no effect on the control (such as textbox control) -- as there should be another option appear indicating the association has taken place).

 below is the steps to take (as written by MS) -- but this is what I am not getting:

"If the Button Tasks shortcut menu does not appear, right-click the Button control and then click Show Smart Tag."  -- the smart tag is not appearing

To add an AJAX extender control
Switch to Design view.

If the page does not already contain a ScriptManager control, from the AJAX Extensions tab of the Toolbox, drag one onto the page.

A ScriptManager c

Want to create Online Business Card designing functionality


 I am going to create Online Business Card designing functionality.

 I am newbie regarding graphics in asp.net. I want to create exactly like following site.




I have some questions


1) How can I write user text in existing image on the fly?

2) How to embed that with aspx page?

3) How to generate it with user inputs like text, font color, size?


Please give me any tutorial URL or any link that could help. Is there any compo

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

Smart Clients: New Guidance And Tools For Building Integrated Desktop Applications


Integrated Desktop is a loosely coupled hosting architecture and composite UI that runs on the desktop and is supported by a loosely coupled architecture on the back end. It collapses the number of applications a user must deal with when making decisions.

Christian Thilmany and Jim Keane

MSDN Magazine September 2006

Editor's Note: When Did Clients Get So Smart?


This issue marks the sixth anniversary of our merger, when Microsoft Systems Journal and Microsoft Internet Developer combined to become MSDN Magazine. We've been around to witness the birth and growth of the Microsoft .

MSDN Magazine March 2006

Smart Clients: Build A Windows Forms Control To Consume And Render WSRP Portlets


Smart client apps use local resources, provide a rich client experience, and support intelligent install mechanisms. Web services offer powerful interoperability and integration features. Find out how to combine them to develop integrated apps that incorporate data from disconnected sources.

Carl Nolan

MSDN Magazine February 2006

Smart Clients: Craft A Rich UI For Your .NET App With Enhanced Windows Forms Support


The System.Windows.Forms namespace has increased by approximately 134 percent over the .NET Framework 1.1. There are 446 new public types; 113 existing types have been updated with new members and values; 218 types have been carried over from the original namespace. Read about it here.

Chris Sells and Michael Weinhardt

MSDN Magazine Visual Studio 2005 Guided Tour 2006

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