C
C#14mo ago
tftviking

Can't get Certificates when uploaded to Azure, works local.

I have built a web app that functions perfectly in my local environment. However, when I deploy it to Azure as a web app, I encounter issues with certificates, they cant be find in the Cert DIR. Its using : https://github.com/RickardPettersson/swish-api-csharp https://pastebin.com/Vbb9g4Nj Your insights and suggestions on how to resolve this issue would be greatly appreciated. Thank you!
GitHub
GitHub - RickardPettersson/swish-api-csharp: Swish For Merchant API...
Swish For Merchant API Client .Net Standard Library - GitHub - RickardPettersson/swish-api-csharp: Swish For Merchant API Client .Net Standard Library
Pastebin
using System;using System.IO;using Microsoft.AspNetCore.Mvc;using M...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
10 Replies
Pobiega
Pobiega14mo ago
best practice would be moving the pfx to a key vault for sure but for this, validate what Environment.CurrentDirectory is when running in azure, it might not be what you expect it to be
tftviking
tftvikingOP14mo ago
I actually was able to make it to the right path but the I got Permission issues. I think you cant load certs from a dir in a Wep App? I get this System.Security.Cryptography.CryptographicException: Access is denied. at System.Security.Cryptography.X509Certificates.StorePal.Add(ICertificatePal certificate) at System.Security.Cryptography.X509Certificates.X509Store.Add(X509Certificate2 certificate) at SwishApi.PayoutClient.PrepareHttpClientAndHandler(HttpClientHandler& handler, HttpClient& client) at SwishApi.PayoutClient.MakePayoutRequest(String payoutTo, String personalNumber, Decimal amount, String message, String instructionUUID, String signingCertificateSerialNumber, ClientCertificate signingCertificate) I have the cert uploaded in Azure but i don't get it to work. I try to find them using thumbprints but its not working at all.
Pobiega
Pobiega14mo ago
wdym "cert uploaded in azure" that can mean a thousand things in a keyvault?
tftviking
tftvikingOP14mo ago
In the Certificates, own pfx Not Key Vault
Pobiega
Pobiega14mo ago
? In what resource? The web app?
tftviking
tftvikingOP14mo ago
No description
Pobiega
Pobiega14mo ago
alright, have never worked with that. check the "read more" link since its azure, it will most likely contain a C# sample of what you need to do to access the cert
tftviking
tftvikingOP14mo ago
Now i find the certs: Certificates found: Certificate 1: CN=1234679304, O=5560997982, C=SE Certificate 2: CN=1234679304, O=5560997982, C=SE System.NullReferenceException: Object reference not set to an instance of an object. at SwishApi.Misc.ReadFully(Stream input) at SwishApi.Models.PayoutRequestEnvelope.buildSignature(ClientCertificate signingCertificate) at SwishApi.PayoutClient.MakePayoutRequest(String payoutTo, String personalNumber, Decimal amount, String message, String instructionUUID, String signingCertificateSerialNumber, ClientCertificate signingCertificate) But its not working xD
Pobiega
Pobiega14mo ago
¯\_(ツ)_/¯ something is null. maybe the private key? or no, that should throw an access violation if the private key couldn't be read
tftviking
tftvikingOP14mo ago
Now the code looks like this https://pastebin.com/WrQHbjam
Pastebin
using System;using System.Security.Cryptography.X509Certificates;us...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Want results from more Discord servers?
Add your server