C# - Non-Interactive Login Sample - CERT_AUTH_REQUIRED

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r4ge
    Junior Member
    • Nov 2014
    • 24

    #1

    C# - Non-Interactive Login Sample - CERT_AUTH_REQUIRED

    I have used the above example code to login and now appear to be getting the error - CERT_AUTH_REQUIRED.

    I had this working a couple of days ago. Now the code or certificate hasn't changed. Why am I now getting this error.
  • r4ge
    Junior Member
    • Nov 2014
    • 24

    #2
    I've create a new certificate, uploaded the certificate to betfair security page.

    certFilename - I have this set to "C:\\TestApp1.crt", which is the location of the certificate, I also have the client-2048.pem in the same root.

    Still getting the message CERT_AUTH_REQUIRED
    Certificate required or certificate present but could not authenticate with it

    Well I know it's the right path and it's not running through to the certificate not found error.

    Can anyone help?

    Comment

    • BetfairDeveloperProgram
      Administrator
      • Oct 2008
      • 679

      #3
      Hi r4ga,

      Have you converted your key to a PKCS12 File as per the sample code instructions via https://github.com/betfair/API-NG-sa...ractive-cSharp ?

      Thanks

      Neil

      Comment

      • r4ge
        Junior Member
        • Nov 2014
        • 24

        #4
        Hi Neil

        Many thanks for your response.
        I am using the XCA software to create the certificate. I believe I have created this incorrectly somewhere down the line.

        From the API-ING reference guide, this shows to export the certificate with the format of "PEM". This will create the certificate to upload. But I have no understanding of how I go about creating the PKCS#12, as exporting this seems to create a .p12 but not a certificate.

        Can you advise how I would do this with XCA?

        Regards

        Andrew

        Comment

        • BetfairDeveloperProgram
          Administrator
          • Oct 2008
          • 679

          #5
          Hi Andrew,

          The PKCS #12 is used to store the key and certificate (in a .p12). So if you export this using XCA and then refer to this as the location of the certificate, this should be successful.

          Thanks

          Neil

          Comment

          • r4ge
            Junior Member
            • Nov 2014
            • 24

            #6
            Finally got this to work, thanks for your help
            Last edited by r4ge; 15-02-2015, 07:44 PM.

            Comment

            • maxspeed
              Junior Member
              • Aug 2014
              • 6

              #7
              Originally posted by r4ge View Post
              Finally got this work, thanks for your help
              Could you please help me?
              I do the same write above with xca
              but always have: CERT_AUTH_REQUIRED

              Comment

              • r4ge
                Junior Member
                • Nov 2014
                • 24

                #8
                I presume you are using .net

                Also make sure it is signed. On the certificate tab in XCA, make sure there is a green tick under CA. Sometimes I would follow the process and the certificate didn't get signed (guessed I missed something somewhere).

                I had to export the certificate twice.

                Once as PEM

                Second as PKCS #12

                Upload the certificate to Betfair (.crt)

                Then reference the cert as the p12 file

                Example:
                cert = "C:\\betfairapp.p12";

                Comment

                • sibur
                  Junior Member
                  • Nov 2017
                  • 4

                  #9
                  I struggled with this on and off for days - this is what I did to get it to work (in Windows 10) hope it helps!

                  open powershell with elevated privs


                  Install openssl using chocolatey :
                  choco install openssl.light

                  cd C:\Betfair login

                  Create a public/private RSA key pair using openssl
                  openssl genrsa -out client-2048.key 2048
                  Locate ssl config file in openssl installation folder : openssl.cfg
                  Add following to config…
                  [ ssl_client ]
                  basicConstraints = CA:FALSE
                  nsCertType = client
                  keyUsage = digitalSignature, keyEncipherment
                  extendedKeyUsage = clientAuth


                  Create a certificate signing request (CSR).
                  openssl req -new -config "c:\program files\openssl-win64\bin\openssl.cfg" -key
                  client-2048.key -out client-2048.csr

                  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]:yourcompany.com
                  Organizational Unit Name (eg, section) []:Security Team
                  Common Name (e.g. server FQDN or YOUR name) []:Test API-NG Certificate
                  Email Address []:my.name@mydomain.com

                  Please enter the following 'extra' attributes
                  to be sent with your certificate request
                  A challenge password []:
                  An optional company name []:
                  Self-sign the certificate request to create a certificate
                  openssl x509 -req -days 365 -in client-2048.csr -signkey client-2048.key -out client-2048.crt -extfile "c:\program files\openssl-win64\bin\openssl.cfg" -extensions ssl_client

                  Create the PKCS#12 format using crt and key
                  openssl pkcs12 -export -in client-2048.crt -inkey client-2048.key
                  -out client-2048.p12
                  Load into VS https://github.com/betfair/API-NG-sa...ractive-cSharp

                  add program lines:
                  ServicePointManager.Expect100Continue = true;
                  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                  Change endpoint
                  private const string DEFAULT_COM_BASEURL = "https://identitysso-cert.betfair.com";

                  Set command line args as
                  <username> <appkey> "C:\Betfair login\client-2048.p12"

                  When run enter your password
                  Login should "SUCCESS"

                  Comment

                  Working...
                  X