Certificate folder not found

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Certificates
    Junior Member
    • Nov 2019
    • 2

    #1

    Certificate folder not found

    HI all,

    Package installed: betfairlightweight 1.10.4
    I am using the following code and i keep getting the following error:

    Exception: Certificate folder not found in C:\Users\Sean\Desktop\certs

    # Import libraries
    import betfairlightweight
    from betfairlightweight import filters
    import pandas as pd
    import numpy as np
    import os
    import datetime
    import json

    # Change this certs path to wherever you're storing your certificates
    certs_path = r'C:\Users\Sean\Desktop\certs'

    When i copy the filepath from file explorer it matched with what i put in the code so im not too sure why it cant find it:

    Filepath - C:\Users\Sean\Desktop\certs
    File inside is - TeskApp.crt

    Any help would be greatly appreciated.

    Kind Regards

    Sean
  • LiamP
    Junior Member
    • Oct 2015
    • 284

    #2
    It is expecting two files, .crt and .key

    Comment

    • Certificates
      Junior Member
      • Nov 2019
      • 2

      #3
      Hi,

      thanks for the quick reply, when I export the key it a saved as a .pem file.

      Can I just change the extension of this to .key ?


      #Update, I change the .pem to .key and it’s working now, thanks for your help
      Last edited by Certificates; 16-11-2019, 08:25 AM.

      Comment

      • Testify467
        Junior Member
        • Dec 2019
        • 5

        #4
        I had the same problem, I did rename the .pem file to .key and it got past that issue, but ultimately gives an error:

        betfairlightweight.login.exceptions.LoginError: API Login: CERT_AUTH_REQUIRED

        I had previously uploaded the .crt file to the betfair account and it does show it there. If I Delete that file, my python login script gives the same exact error. I am using the python sample in the API tutorial (below) and have version 1.6.2 of betfairlightweight. My certs folder contains 3 files, (with xxxxx and zzzzz being words I've chosen). Thanks for your assistance.

        xxxxx_key.key
        xxxxx_zzzzz.crt
        xxxxx_zzzzz.pem
        _________________

        # Import libraries
        import betfairlightweight
        from betfairlightweight import filters
        import pandas as pd
        import numpy as np
        import os
        import datetime
        import json

        # Change this certs path to wherever you're storing your certificates
        certs_path = r'C:\certs'

        # Change these login details to your own
        my_username = 'xxxxx'
        my_password = 'xxxxxxx'
        my_app_key = 'xxxxxxxxxxxx'

        trading = betfairlightweight.APIClient(username=my_username,
        password=my_password,
        app_key=my_app_key,
        certs=certs_path)

        trading.login()

        ____________________

        on Betfair the Automated Betting Program Access line shows:

        CN=IDAP,OU=IDAP,O=IDAP,L=London,ST=JS,C=GB,E=james krav@gmail.com

        when I check the certificate it shows virtually the same thing, but does list the 'state' abbreviation
        as S instead of ST, if that makes any difference

        E = jameskrav@gmail.com
        CN = IDAP
        OU = IDAP
        O = IDAP
        L = London
        S = JS
        C = GB
        ____________

        I did have SUCCESS with the 'non-interactive (bot) login code' they provide

        payload = 'username=xxxxxxx@gmail.com&password=xxxxx'
        headers = {'X-Application': 'xxxxxxxxx', 'Content-Type': 'application/x-www-form-urlencoded'}

        resp = requests.post('https://identitysso-cert.betfair.com/api/certlogin', data=payload, cert=('c:\certs\client-2048.crt', 'c:\certs\client-2048.key'), headers=headers)

        if resp.status_code == 200:
        resp_json = resp.json()
        print resp_json['loginStatus']
        print resp_json['sessionToken']
        else:
        print "Request failed."
        Last edited by Testify467; 01-05-2020, 09:17 AM.

        Comment

        • Testify467
          Junior Member
          • Dec 2019
          • 5

          #5
          problem resolved itself when I updated to 1.10.1

          Comment

          Working...
          X