
Ergebnis 1 bis 4 von 4
-
Mich gibt's schon länger
- 30.07.2015, 07:37
- #1
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.
Code: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); }
Code: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?
-
Mich gibt's schon länger
- 31.07.2015, 12:45
- #2
Habs jetzt auch mit der HttpClient Klasse dem Windows.Web.Http Namepsace versucht aber leider ohne erfolg
Code:using (HttpClient client = new HttpClient()) { HttpStringContent content = new HttpStringContent("Hallo, ich bin eine App!"); //HttpResponseMessage response = await client.PostAsync(uri, content); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, uri); HttpResponseMessage response = await client.SendRequestAsync(message); }
Niemand der das schonmal gemacht hat oder so?
Währe wirklich sehr dankbar für Hilfe
-
- 31.07.2015, 13:04
- #3
Ich glaube nicht das es möglich ist gegen localhost (https://127.0.0.1:4712/) eine SSL Verbindung aufzumachen.
Ich hab nen VirtualServer mit nem echten Zertifikat dafür.
---
Ich nutze immer RestSharp bzw. RestSharp portable, welches man über NuGet beziehen kann.
Und dann so:
private RestClient restClient;
private string baseUri = "https://meinserverort/ABCService";
...
restClient = new RestClient(baseUri);
...
string uri = "Login";
restClient.Authenticator = new HttpBasicAuthenticator(basicUser, basicPass);
var request = new RestRequest(uri, HttpMethod.Get);
request.AddParameter("nocache", DateTime.Now.Ticks);
var response = await restClient.Execute(request);
return response;
-
Bin hier zuhause
- 31.07.2015, 13:15
- #4
In einer meiner Testapps benutze ich den httpClient ebenfalls via ssl (https), dies funktioniert einwandfrei. Wie akunz schon schrieb, solltest du den Host anpassen. Zudem brauchst du ein Zertifikat von deinem Webserver, dies musst du auf deinem Phone installieren.
Mfg andy66
Mit der kostenlosen PocketPC.ch App von meinem Nokia Lumia 1520 aus geschrieben.
Ähnliche Themen
-
Auslesen einer Website mittels HttpClient
Von Agredo im Forum Windows Phone 8 EntwicklungAntworten: 4Letzter Beitrag: 25.12.2014, 21:24 -
Zugriff auf https://host.domain.de:445 ?
Von marioh im Forum Samsung Galaxy SAntworten: 2Letzter Beitrag: 10.12.2012, 12:46 -
kein zugriff auf Adressen mit https\\
Von thasini im Forum HTC Touch DiamondAntworten: 1Letzter Beitrag: 24.09.2010, 18:43 -
netzwerkfehler + https probleme
Von zenon69 im Forum HTC Desire KommunikationAntworten: 4Letzter Beitrag: 14.07.2010, 19:19 -
https-Seiten mit dem QTek S100
Von peterschoenthal im Forum Qtek Forum (PPC)Antworten: 10Letzter Beitrag: 29.07.2005, 18:13
Pixel 10 Serie mit Problemen:...