G
Guest
Hello,
i am trying to make an Https request to a coradiant box. the box monitors
perforamnce of our website. when i paste the url into IE i am asked to accept
a ceritificate. then i get a dialog box asking where to save the file. I have
written a C# application. the will make the https request and i am stroring
the responces in a stream. but i cant read the stream i get an error the
stream does not support seek operations. here is url and the code that i am
have written can someone tell me whats i amdoing wrong thanks
https://truesight/wpdata?usr=xxxx&pwd=xxxxx&timeframe=fullday&format=CSV&zip=false
internal class AcceptAllCertificatePolicy : ICertificatePolicy
{
public AcceptAllCertificatePolicy()
{
}
public bool CheckValidationResult(ServicePoint sPoint,
X509Certificate cert, WebRequest wRequest,int certProb)
{
// Always accept
return true;
}
}
private void btnGetData_Click(object sender, System.EventArgs e)
{
try
{
ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
string rq =
System.Configuration.ConfigurationSettings.AppSettings.GetValues("httpReq").GetValue(0).ToString().Replace("%20","&");
//X509Certificate Cert =
X509Certificate.CreateFromCertFile("192.168.0.199");
X509Certificate Cert =
X509Certificate.CreateFromCertFile(@"C:\\Documents and Settings\afloyd\My
Documents\Truesight\TSDateExtractor\bin\Debug\ts.cer");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(rq);
//req.ClientCertificates
req.ClientCertificates.Add(Cert);
req.UserAgent = "Client Cert Sample";
req.Method = "GET";
HttpWebResponse Response = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = Response.GetResponseStream();
byte[] bytes = new byte[1000];
int numBytesToRead = 5000;
int numBytesRead = 500;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = ReceiveStream.Read(bytes, numBytesRead, numBytesToRead);
// The end of the file is reached.
if (n==0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
ReceiveStream.Close();
}
catch (System.Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
i am trying to make an Https request to a coradiant box. the box monitors
perforamnce of our website. when i paste the url into IE i am asked to accept
a ceritificate. then i get a dialog box asking where to save the file. I have
written a C# application. the will make the https request and i am stroring
the responces in a stream. but i cant read the stream i get an error the
stream does not support seek operations. here is url and the code that i am
have written can someone tell me whats i amdoing wrong thanks
https://truesight/wpdata?usr=xxxx&pwd=xxxxx&timeframe=fullday&format=CSV&zip=false
internal class AcceptAllCertificatePolicy : ICertificatePolicy
{
public AcceptAllCertificatePolicy()
{
}
public bool CheckValidationResult(ServicePoint sPoint,
X509Certificate cert, WebRequest wRequest,int certProb)
{
// Always accept
return true;
}
}
private void btnGetData_Click(object sender, System.EventArgs e)
{
try
{
ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
string rq =
System.Configuration.ConfigurationSettings.AppSettings.GetValues("httpReq").GetValue(0).ToString().Replace("%20","&");
//X509Certificate Cert =
X509Certificate.CreateFromCertFile("192.168.0.199");
X509Certificate Cert =
X509Certificate.CreateFromCertFile(@"C:\\Documents and Settings\afloyd\My
Documents\Truesight\TSDateExtractor\bin\Debug\ts.cer");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(rq);
//req.ClientCertificates
req.ClientCertificates.Add(Cert);
req.UserAgent = "Client Cert Sample";
req.Method = "GET";
HttpWebResponse Response = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = Response.GetResponseStream();
byte[] bytes = new byte[1000];
int numBytesToRead = 5000;
int numBytesRead = 500;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = ReceiveStream.Read(bytes, numBytesRead, numBytesToRead);
// The end of the file is reached.
if (n==0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
ReceiveStream.Close();
}
catch (System.Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}