client certificate for WCF RRS feed

  • Question

  • User-2082897069 posted

    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)


                ws1.ClientCredentials.ClientCertificate.SetCertificate( _
                    System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser, _
                    System.Security.Cryptography.X509Certificates.StoreName.My, _
                    System.Security.Cryptography.X509Certificates.X509FindType.FindByApplicationPolicy, _
            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)

    FindByApplicationPolicy The 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 "" 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?


    LIMS Consultant

    BtB Software

    Thursday, May 29, 2014 12:34 PM