RickardPettersson / swish-api-csharp

Swish For Merchant API Client .Net Standard Library
MIT License
29 stars 14 forks source link

Cant get swish merchant to work with memorystream #25

Closed ludvigbartholdsson closed 3 months ago

ludvigbartholdsson commented 2 years ago

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

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 commented 2 years ago

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"
        };

`

RickardPettersson commented 2 years ago

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 commented 1 year ago

Still some problems or can i close this?

RickardPettersson commented 3 months ago

I closing this now without any comments over a year