Hello, Support,
please advise me:
use follow code on c# to login in betfair but got error CERT_AUTH_REQUIRED. Where is my bug?
Thanks
try
{
const string postData = "username=myusername&password=mypassw";
System.Security.Cryptography.X509Certificates.X509 Certificate2 x509certificate = new System.Security.Cryptography.X509Certificates.X509 Certificate2("C:\\OpenSSL-Win32\\bin\\client-2048.pem", "xxxx"); //------ where xxxx - password was mentioned in process of ssl-key generation
/*
Country Name (2 letter code) [AU]:GB
State or Province Name (full name) [Some-State]:London
Locality Name (eg, city) []:London
Organization Name (eg, company) [Internet Widgits Pty Ltd]:myname
Organizational Unit Name (eg, section) []:trader
Common Name (e.g. server FQDN or YOUR name) []:myname
Email Address []:myemail@myemail.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:xxxx
An optional company name []:myname
*/
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://identitysso-api.betfair.com/api/certlogin");
request.UseDefaultCredentials = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add("X-Application", appkey);
request.ClientCertificates.Add(x509certificate);
request.Accept = "*/*";
request.Proxy = null;
using (Stream stream = request.GetRequestStream())
{
using (StreamWriter writer = new StreamWriter(stream, Encoding.Default))
{
writer.Write(postData);
}
}
using (Stream stream = ((HttpWebResponse)request.GetResponse()).GetRespon seStream())
{
using (StreamReader reader = new StreamReader(stream, Encoding.Default))
{
var jsonResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<Logi nResponse>(reader.ReadToEnd());
if (jsonResponse.loginStatus == "SUCCESS")
{
//saveSession(jsonResponse.sessionToken);
bool loginSucceeded = true;
}
else
{
System.Media.SystemSounds.Exclamation.Play();
}
}
}
}
catch (System.Exception ex)
{
System.Media.SystemSounds.Exclamation.Play();
//MessageBox.Show(ex.ToString(), "Login ERROR");
}
please advise me:
use follow code on c# to login in betfair but got error CERT_AUTH_REQUIRED. Where is my bug?
Thanks
try
{
const string postData = "username=myusername&password=mypassw";
System.Security.Cryptography.X509Certificates.X509 Certificate2 x509certificate = new System.Security.Cryptography.X509Certificates.X509 Certificate2("C:\\OpenSSL-Win32\\bin\\client-2048.pem", "xxxx"); //------ where xxxx - password was mentioned in process of ssl-key generation
/*
Country Name (2 letter code) [AU]:GB
State or Province Name (full name) [Some-State]:London
Locality Name (eg, city) []:London
Organization Name (eg, company) [Internet Widgits Pty Ltd]:myname
Organizational Unit Name (eg, section) []:trader
Common Name (e.g. server FQDN or YOUR name) []:myname
Email Address []:myemail@myemail.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:xxxx
An optional company name []:myname
*/
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://identitysso-api.betfair.com/api/certlogin");
request.UseDefaultCredentials = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add("X-Application", appkey);
request.ClientCertificates.Add(x509certificate);
request.Accept = "*/*";
request.Proxy = null;
using (Stream stream = request.GetRequestStream())
{
using (StreamWriter writer = new StreamWriter(stream, Encoding.Default))
{
writer.Write(postData);
}
}
using (Stream stream = ((HttpWebResponse)request.GetResponse()).GetRespon seStream())
{
using (StreamReader reader = new StreamReader(stream, Encoding.Default))
{
var jsonResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<Logi nResponse>(reader.ReadToEnd());
if (jsonResponse.loginStatus == "SUCCESS")
{
//saveSession(jsonResponse.sessionToken);
bool loginSucceeded = true;
}
else
{
System.Media.SystemSounds.Exclamation.Play();
}
}
}
}
catch (System.Exception ex)
{
System.Media.SystemSounds.Exclamation.Play();
//MessageBox.Show(ex.ToString(), "Login ERROR");
}


Comment