WPA2-Enterprise keyfile and certfile invalid path



  • Hallo!

    I' trying to connect to an WPA2-Enterprise network using WiFi. Unfortunately I'm running into an early error. The connect method is not finding the files and claims that the file path is wrong. But I'm quit sure that the files are there.
    What am I doing wrong ?

    Thanks!

    print("Wifi test")
    wlan = WLAN(mode=WLAN.STA)
    wlan.antenna(WLAN.EXT_ANT)
    file = open("/flash/cert/GoeSubCA_2020.pem", "r")#only for testing the path
    file.close()
    file = open('/flash/cert/GOEHMQ001-client.key','r')#only for testing the path
    file.close()
    file = open('/flash/cert/GOEHMQ001-client.crt','r')#only for testing the path
    file.close()
    
    wlan.connect(ssid= essentials['wifi_ssid'], auth=(WLAN.WPA2_ENT,), identity='GOEHMQ001', keyfile = '/flash/cert/GOEHMQ001-client.key', certfile = '/flash/cert/GOEHMQ001-client.crt')
    
    while not wlan.isconnected():
        WLAN.status()
        machine.idle()
    while True:
        print(wlan.isconnected())
    

    Output: (line 19 is the one with the connect method)

    Pycom MicroPython 1.20.2.r1 [v1.11-a5aa0b8] on 2020-09-09; LoPy4 with ESP32
    Pybytes Version: 1.6.0
    Type "help()" for more information.
    Reading file status
    [1/1] Writing file main.py (3kb)
    Upload done, resetting board...
    OKets Jun 8 2016 00:22:57

    rst:0x7 (TG0WDT_SYS_RESET),boot:0x3b (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff8020,len:8
    load:0x3fff8028,len:2140
    ho 0 tail 12 room 4
    load:0x4009fa00,len:19760
    entry 0x400a05bc
    Wifi test
    Traceback (most recent call last):
    File "main.py", line 19, in <module>
    ValueError: invalid file path



  • Well, it could also be a problem on my side, let me know what you get!



  • Hi,
    thanks for your answer! I uploaded the new firmware and the error is not showing up anymore. Unfortunately I can not establish a connection but this might be a problem with the files itself. To verify this I have to speak with peoples of our IT department.
    I will report to this next week!



  • Hi,

    Today I had some time to dive deeper into this issue. Its quite complicated though and Ill try my best to explain it here:

    It seems the function that loads the certificate files is added in the wlan = WLAN() operation, though that does not accept the keyword arguments for these files.

    Then wlan.connect() assumes the files are already read and then discovers they are 'empty', returning a bad-file error.

    I have now implemented the read-file function before the files are needed, probably solving the issue (I dont have a WPA2-ENT network to test with currently).

    I attached the custom firmware here, let me know if that works for you! You can upload it using the firmware updater. I can also compile a version with Pybytes/Pygate if that is what you need!
    Gijs

    https://we.tl/t-mB7AYPTzm7

    NB. you use the function WLAN.status(), that does not seem to exist


Log in to reply
 

Pycom on Twitter