G
Guest
my asp.net app is posting to another webpage using httpwebRequest &
x509Certificates and in return the certificate's name used for the posting is
sent back. But instead of getting information about the cert returned I'd get
no information message.
I know my certificate is valid because when I manually type the address my
app is posting to in IE it would return the client certificate's name used in
my users personal store.
So basically, HttpwebRequest is not sending the client certificate.
I have the cert installed in local_machine\personal store in CA in the
trusted root authority.
I'm also using window server 2003
code that POSTs:
void SendTestXML2(object sender, System.EventArgs e)
{
string XMLRequest = "";
System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
try
{
string loginUrl =
"https://aestheticpc.com/qbConn/CertCheck/CertCheckaspx.aspx"; XMLRequest =
buildXML();
X509Certificate cert =
X509Certificate.CreateFromCertFile("ClientCertDER2.cer");
HttpWebRequest wr = (HttpWebRequest) WebRequest.Create(loginUrl);
wr.ClientCertificates.Add(cert);
wr.Method = "POST";
wr.KeepAlive = false;
wr.ContentType = "application/x-qbxml";
wr.ContentLength = XMLRequest.Length;
// send xml data
StreamWriter SendStream;
SendStream = new StreamWriter(wr.GetRequestStream());
SendStream.Write(XMLRequest);
SendStream.Flush();
SendStream.Close();
HttpWebResponse WebResp = (HttpWebResponse) wr.GetResponse();
string res = "";
using (StreamReader sr = new
StreamReader(WebResp.GetResponseStream()) )
{
res = sr.ReadToEnd();
sr.Close();
}
Output.Text = res.ToString();
Output.Text += cert.GetName();
WebResp.Close();
}
catch(Exception err)
{
Response.Write(err.ToString() + "<br>");
Response.Write(XMLRequest.ToString());
}
}
code that Responds:
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim cs As HttpClientCertificate = Request.ClientCertificate
If cs.IsPresent Then
'Get the Organization (O) field from the Subject section.
Response.Write("Cert subject: " & cs.Get("Subject O"))
Else
Response.Write("No certificate was found.")
End If
End Sub
x509Certificates and in return the certificate's name used for the posting is
sent back. But instead of getting information about the cert returned I'd get
no information message.
I know my certificate is valid because when I manually type the address my
app is posting to in IE it would return the client certificate's name used in
my users personal store.
So basically, HttpwebRequest is not sending the client certificate.
I have the cert installed in local_machine\personal store in CA in the
trusted root authority.
I'm also using window server 2003
code that POSTs:
void SendTestXML2(object sender, System.EventArgs e)
{
string XMLRequest = "";
System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
try
{
string loginUrl =
"https://aestheticpc.com/qbConn/CertCheck/CertCheckaspx.aspx"; XMLRequest =
buildXML();
X509Certificate cert =
X509Certificate.CreateFromCertFile("ClientCertDER2.cer");
HttpWebRequest wr = (HttpWebRequest) WebRequest.Create(loginUrl);
wr.ClientCertificates.Add(cert);
wr.Method = "POST";
wr.KeepAlive = false;
wr.ContentType = "application/x-qbxml";
wr.ContentLength = XMLRequest.Length;
// send xml data
StreamWriter SendStream;
SendStream = new StreamWriter(wr.GetRequestStream());
SendStream.Write(XMLRequest);
SendStream.Flush();
SendStream.Close();
HttpWebResponse WebResp = (HttpWebResponse) wr.GetResponse();
string res = "";
using (StreamReader sr = new
StreamReader(WebResp.GetResponseStream()) )
{
res = sr.ReadToEnd();
sr.Close();
}
Output.Text = res.ToString();
Output.Text += cert.GetName();
WebResp.Close();
}
catch(Exception err)
{
Response.Write(err.ToString() + "<br>");
Response.Write(XMLRequest.ToString());
}
}
code that Responds:
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim cs As HttpClientCertificate = Request.ClientCertificate
If cs.IsPresent Then
'Get the Organization (O) field from the Subject section.
Response.Write("Cert subject: " & cs.Get("Subject O"))
Else
Response.Write("No certificate was found.")
End If
End Sub