Sending soap request with X509 Certificate that uses sha256 signing algorithm

ITMemberAHE 6 Reputation points
2021-08-20T09:16:39.457+00:00

I'm trying to make a soap service.

To send request I need to use X509 Certificate. I used X509Certificate2 class for that purpose, because client that was generated automatically had this one. The problem is that its keys are System.Security.Cryptography.RSACryptoServiceProvider class that accepts only "http://www.w3.org/2000/09/xmldsig#rsa-sha1" signature algorithm. In our case sha256 signature algorithm is needed.

Have you got any idea how can I deal with that?

Code looks like this:

 SoapService.GetOrderStatusRequest request = new SoapService.GetOrderStatusRequest()
        {
            orderId = Int32.Parse(txtID.Text),
            requestHeader = new SoapService.RequestHeader() 
            { 
                 institutionId = 123, 
                 requestId = "aeacbff8-ba6d-4a01-8e76-0b4384c24721", 
                 system = "Test" 
            }
        };
        var cert = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + "//cert.p12", "Passs123");

        client.ChannelFactory.Credentials.ClientCertificate.Certificate = cert;
        client.ClientCredentials.ClientCertificate.Certificate = cert;

        SoapService.GetOrderStatusResponse response = client.getOrderStatus(request);
        txtResult.Text = response.order.name;
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,415 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,306 questions
{count} votes