swish-api-csharp icon indicating copy to clipboard operation
swish-api-csharp copied to clipboard

Cant get swish merchant to work with memorystream

Open ludvigbartholdsson opened this issue 3 years ago • 3 comments

I am unable to get Swish Merchant (mCommerce) to work with cert-load via memorystream.

  • Same certificate (Tls/client, not signing) used as in Payouts. Works in Payouts.
  • Emulator-mode.

Error:

2022-10-03T12:33:39.819817189Z Unable to start make Swish payment request with error: System.AggregateException: One or more errors occurred. (The SSL connection could not be established, see inner exception.) 2022-10-03T12:33:39.819833890Z ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. 2022-10-03T12:33:39.819839990Z ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. 2022-10-03T12:33:39.819844790Z ---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL. 2022-10-03T12:33:39.819849390Z ---> Interop+Crypto+OpenSslCryptographicException: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure 2022-10-03T12:33:39.819854390Z --- End of inner exception stack trace ---

ludvigbartholdsson avatar Oct 03 '22 14:10 ludvigbartholdsson

Test:

Try to load the certificate-file to a memorystream like this:

https://github.com/RickardPettersson/swish-api-csharp/blob/master/SwishApiConsoleTest/Program.cs#L110

` MemoryStream ms = new MemoryStream(); using ( FileStream fs = File.OpenRead( "TestCert//Swish_Merchant_TestCertificate_1234679304.p12" ) ) { fs.CopyTo(ms); }

        var clientCertificate = new SwishApi.Models.ClientCertificate()
        {
            CertificateAsStream = ms,
            UseMachineKeySet = true,
            Password = "swish"
        };

`

ludvigbartholdsson avatar Oct 03 '22 14:10 ludvigbartholdsson

The test console application works fine for me on windows debuging in visual studio and if i chang ethe code to read in to memorystream like you write above then i getting error when it try to read the stream that it not find any certificate instead...

RickardPettersson avatar Oct 20 '22 08:10 RickardPettersson

Still some problems or can i close this?

RickardPettersson avatar May 12 '23 13:05 RickardPettersson

I closing this now without any comments over a year

RickardPettersson avatar Aug 10 '24 09:08 RickardPettersson