0

I have the C# code below which works, I want to write the same thing in java.

My searches on Stack Overflow were unsuccessful, all of the questions have a .pem file in use.

I realize that it must be pretty straightforward, but I'm stuck with this since a week!

string serviceURL = "https://someurl";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceURL);
request.Method = "GET";
string path = @"C:\mycert.cer";
X509Certificate Cert = X509Certificate.CreateFromCertFile(path);

Logger.Error(path);

request.ClientCertificates.Add(Cert);

HttpWebResponse WebResp = request.GetResponse() as HttpWebResponse;

var encoding = ASCIIEncoding.ASCII;
string responseText;
StreamReader reader = new System.IO.StreamReader(WebResp.GetResponseStream(), encoding);
using (reader = new System.IO.StreamReader(WebResp.GetResponseStream(), encoding))
{
    responseText = reader.ReadToEnd();
}
zanussi
  • 1,286
  • 2
  • 22
  • 29

0 Answers0