WCF Certificate Store from SQL Server Database

I have an SQL database that stores my client-side certificate for WCF service and other services. (X509 etc.). I would like to use this Store (instead of β€œMy”) to get this certificate (instead of declaring it in web.config), and then use it for WCF.

I tried doing a search on this site and google, but it doesn't seem to help much.

I'm currently doing

var targetEndpoint = new EndpointAddress(targetLogicalAddress, targetIdentity); MyTransportPortTypesClient proxy = new MyTransportPortTypesClient("WebConfigSection", targetEndpoint); 

Ideally, I would like to get rid of the "WebConfigSection" and instead pass in some kind of WCF object signed with a certificate.

Does anyone know how to achieve this?


I finally solved it and that’s how I did it. (I shared my experience so that everyone can use it). This is without using any CertificateStore certificate. Its pure from database to client proxy.

I created an X509Certificate2 object and assigned a physical file (in byte []). You can also put a password if its password is protected.

Then I assigned a certificate to my proxy client. Sort of:

 proxy.ClientCredentials.ClientCertificate = __MyCertificate 

Now I have manupulated my clientproxy, as I was inteneted in my app.config. what is it. All these properties will be in your proxy object.

Hope this helps.

+3
source share
1 answer

AFAIK is, at least, very difficult, if not right, then impossible. WCF uses the SCHannel SSPI provider for authentication, and this SSPI provider will only download certificates from the SCHANNEL CSP Provider . To use the certificate from the database, the certificate must first be uploaded to the PROV_RSA_SCHANNEL CSP key store , and then the certificate context of this key store will go to the AcquireCredentialsHandle . For example, in this way, database mirroring can be authenticated using a certificate stored in the database . Although you can also do all of these steps in managed code, I'm not sure if you can connect them to WCF: I expect this to be the case, but probably not for the faint of heart.

+1
source

Source: https://habr.com/ru/post/970543/


All Articles