Hallo leute,
ich versuche über die HttpClient Klasse einen https request an meinen Server zu senden. Im Browser klappt das, nur leider nich in meiner App.
in der OnLaunched Methode hab ich folgendes um das Zertifikat hinzuzufügen.
und so versuch ich den RequestCode:
try {
// Read the contents of the Certificate file
Uri certificateFile = new Uri("ms-appx:///Assets/TestSignedByCA.cer");
Windows.Storage.StorageFile file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(certificateFile);
Windows.Storage.Streams.IBuffer certBlob = await Windows.Storage.FileIO.ReadBufferAsync(file);
// Create an instance of the Certificate class using the retrieved certificate blob contents
Windows.Security.Cryptography.Certificates.Certificate rootCert = new Windows.Security.Cryptography.Certificates.Certificate(certBlob);
// Get access to the TrustedRootCertificationAuthorities for your own app (not the system one)
Windows.Security.Cryptography.Certificates.CertificateStore trustedStore = Windows.Security.Cryptography.Certificates.CertificateStores.TrustedRootCertificationAuthorities;
// Add the certificate to the TrustedRootCertificationAuthorities store for your app
trustedStore.Add(rootCert);
}
catch (Exception oEx)
{
// Catch and report exceptions
System.Diagnostics.Debug.WriteLine("Exception Adding cert: " + oEx.Message);
}
response ist Status 404Code:HttpClientHandler aHandler = new HttpClientHandler();
//aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic; -hab ich mal ausprobiert
using (HttpClient client = new HttpClient(aHandler))
{
client.BaseAddress = new Uri("https://127.0.0.1:4712/");
StringContent content = new StringContent("hallo, ich bin eine App!");
HttpResponseMessage response = await client.PostAsync("index/", content);
}
lass ich es über eine normale http laufen funktioniert es
Hat jemand rat?