Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

client certificate for WCF

$
0
0

I have defined a web client for an external web SOAP service secured by a certificate and user name and password.

I want to use the following code to instantiate the web client and set the credential for the client.

            ws1 = New CDPHService.CDPH_transferPortTypeClient(contractName, EndPoint)

        Try

            ws1.ClientCredentials.ClientCertificate.SetCertificate( _
                System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser, _
                System.Security.Cryptography.X509Certificates.StoreName.My, _
                System.Security.Cryptography.X509Certificates.X509FindType.FindByApplicationPolicy, _
                "cdph")
        Catch ex As Exception
            MsgBox("set certificate error " + Err.Number.ToString + Chr(10) + ex.Message)
        End Try

This system is running Windows 8.1 Pro,  I am developing in Visual Basic with Visual Studio 2012.  The application references .Net Framework 4

Windows 8.1 certificate manager shows the certificate with the friendly name "cdph"

The MSDN reference for X509FindType.FindByApplicationPolicy states specifically that FindByApplicationPolicy wants a string with the application policy friendly name.  ( http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509findtype(v=vs.110).aspx)

FindByApplicationPolicyThe findValue parameter for the Find method must be a string representing either the application policy friendly name or the object identifier (OID, orOid) of the certificate. For example, "Encrypting File System" or "1.3.6.1.4.1.311.10.3.4" can be used. For an application that will be localized, the OID value must be used, because the friendly name is localized.

When the SetCertificate statement is executed, it returns error 5 The OID value was invalid.

Why would that error be generated? Or more generally - why isn't the certificate being found?

Jim

LIMS Consultant

BtB Software


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>