Having trouble trying to convert cbor object to CSR while trying to provision a device

HI all, 

So after realizing that I needed to Just-In-Time provision my Thingy 91 in order to add the device to my nRF Cloud account, I began the process described in this post in the nRF documentation: Generating credentials using AT commands I had been able to successfully obtain the base64-encoded CBOR object and I'm trying to convert that into a CSR through this python script:  modem_credentials_parser.py 

I have the script downloaded and saved in the same folder that Python on my laptop is also saved in. I tried to follow the README.md associated with the script and I'm not able to make it past the required package installations. 

If I go ahead and try to use the script with my CBOR object I get

Traceback (most recent call last):
File "Z:\modem_credentials_parser.py", line 11, in <module>
from cbor2 import loads
ModuleNotFoundError: No module named 'cbor2'

I have both pip and cbor2 installed on my machine so I'm not sure what else I'm missing for these issues to keep coming up? 

Parents Reply Children
  • Hi,

    The issue may arise if you are using a firewall. Maybe you could try using an unrestricted firewall and see if this helps.

    -Priyanka

  • Hi Priyanka! 

    I'm accessing this through a work network and I've been in contact with my IT department and I was able to work through some of my issues and am now in this new position: 

    After being able to configure pip to the CA certificate associated with my place of work I was able to create a virtual environment and update pip to the latest version without throwing an SSL error. I've added this new environment to my PATH and then tried to install my requirements.txt file in order to use the python script associated with my initial task ;-;

    When I enter pip install -r requirements.txt I get the following error:

    Looking in indexes: /*WORK LINK*/
    Collecting auto_mix_prep>=0.2.0 (from -r requirements.txt (line 1))
    Using cached /*WORK LINK*/ s ... done
    Getting requirements to build wheel ... done
    Preparing metadata (pyproject.toml) ... done
    Collecting cbor2>=5.4.2.post1 (from -r requirements.txt (line 2))
    Using cached /*WORK LINK*/ (23 kB)
    Collecting colorama>=0.4.4 (from -r requirements.txt (line 3))
    Using cached /*WORK LINK*/ (25 kB)
    Collecting cryptography>=36.0.1 (from -r requirements.txt (line 4))
    Using cached /*WORK LINK*/ (686 kB)
    Installing build dependencies ... error
    error: subprocess-exited-with-error
    
    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 1
    ╰─> [142 lines of output]
    Looking in indexes: /*WORK LINK*/
    Collecting maturin<2,>=1
    Using cached /*WORK LINK*/ (188 kB)
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
    Collecting cffi>=1.12
    Using cached /*WORK LINK*/ (512 kB)
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
    Collecting setuptools
    Using cached https:/*WORK LINK*/ (2.3 MB)
    Collecting pycparser (from cffi>=1.12)
    Using cached /*WORK LINK*/ (117 kB)
    Building wheels for collected packages: maturin, cffi
    Building wheel for maturin (pyproject.toml): started
    Building wheel for maturin (pyproject.toml): finished with status 'error'
    error: subprocess-exited-with-error
    
    Building wheel for maturin (pyproject.toml) did not run successfully.
    exit code: 1
    
    [42 lines of output]
    C:\Users\rbx5032\AppData\Local\Temp\pip-build-env-p7nrk207\overlay\lib\python3.11\site-packages\setuptools\config\_apply_pyprojecttoml.py:79: SetuptoolsWarning: `install_requires` overwritten in `pyproject.toml` (dependencies)
    corresp(dist, value, root_dir)
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build\lib.mingw_x86_64-cpython-311
    creating build\lib.mingw_x86_64-cpython-311\maturin
    copying maturin\__init__.py -> build\lib.mingw_x86_64-cpython-311\maturin
    copying maturin\__main__.py -> build\lib.mingw_x86_64-cpython-311\maturin
    running egg_info
    creating maturin.egg-info
    writing maturin.egg-info\PKG-INFO
    writing dependency_links to maturin.egg-info\dependency_links.txt
    writing requirements to maturin.egg-info\requires.txt
    writing top-level names to maturin.egg-info\top_level.txt
    writing manifest file 'maturin.egg-info\SOURCES.txt'
    reading manifest file 'maturin.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.json' under directory 'src\python_interpreter'
    adding license file 'license-apache'
    adding license file 'license-mit'
    writing manifest file 'maturin.egg-info\SOURCES.txt'
    running build_ext
    running build_rust
    Updating crates.io index
    warning: spurious network error (3 tries remaining): [35] SSL connect error (schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.)
    warning: spurious network error (2 tries remaining): [35] SSL connect error (schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.)
    warning: spurious network error (1 tries remaining): [35] SSL connect error (schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.)
    error: failed to get `anyhow` as a dependency of package `maturin v1.7.0 (C:\Users\rbx5032\AppData\Local\Temp\pip-install-8tl9iopx\maturin_c7d66aa104f340d6a8375f29f177aa7a)`
    
    Caused by:
    download of config.json failed
    
    Caused by:
    failed to download from `https://index.crates.io/config.json`
    
    Caused by:
    [35] SSL connect error (schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.)
    error: `cargo metadata --manifest-path Cargo.toml --format-version 1 --locked` failed with code 101
    -- Output captured from stdout:
    
    [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for maturin
    Building wheel for cffi (pyproject.toml): started
    Building wheel for cffi (pyproject.toml): finished with status 'error'
    error: subprocess-exited-with-error
    
    Building wheel for cffi (pyproject.toml) did not run successfully.
    exit code: 1
    
    [52 lines of output]
    _configtest.c:2:2: error: #error "not MSVC"
    2 | #error "not MSVC"
    | ^~~~~
    Note: will not use '__thread' in the C code
    ***** The above error message can be safely ignored.
    
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build\lib.mingw_x86_64-cpython-311
    creating build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\api.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\backend_ctypes.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\cffi_opcode.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\commontypes.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\cparser.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\error.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\ffiplatform.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\lock.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\model.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\pkgconfig.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\recompiler.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\setuptools_ext.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\vengine_cpy.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\vengine_gen.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\verifier.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\_imp_emulation.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\_shimmed_dist_utils.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\__init__.py -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\_cffi_include.h -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\parse_c_type.h -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\_embedding.h -> build\lib.mingw_x86_64-cpython-311\cffi
    copying src\cffi\_cffi_errors.h -> build\lib.mingw_x86_64-cpython-311\cffi
    running build_ext
    building '_cffi_backend' extension
    creating build\temp.mingw_x86_64-cpython-311
    creating build\temp.mingw_x86_64-cpython-311\src
    creating build\temp.mingw_x86_64-cpython-311\src\c
    gcc -DNDEBUG -g -fwrapv -O3 -Wall -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -DFFI_BUILDING=1 -IC:/msys64/mingw64/bin/../include -IC:\msys64\mingw64/include/python3.11 -c src/c/_cffi_backend.c -o build\temp.mingw_x86_64-cpython-311\src\c\_cffi_backend.o
    src/c/_cffi_backend.c: In function 'b_do_dlopen':
    src/c/_cffi_backend.c:4521:40: error: passing argument 1 of 'PyUnicode_AsWideChar' from incompatible pointer type [-Wincompatible-pointer-types]
    4521 | sz1 = PyUnicode_AsWideChar((PyUnicodeObject *)filename_unicode,
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | |
    | PyUnicodeObject *
    In file included from C:\msys64\mingw64/include/python3.11/Python.h:51,
    from src/c/_cffi_backend.c:2:
    C:\msys64\mingw64/include/python3.11/unicodeobject.h:299:15: note: expected 'PyObject *' {aka 'struct _object *'} but argument is of type 'PyUnicodeObject *'
    299 | PyObject *unicode, /* Unicode object */
    | ~~~~~~~~~~^~~~~~~
    error: command 'C:\\msys64\\mingw64\\bin\\gcc.EXE' failed with exit code 1
    [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for cffi
    Failed to build maturin cffi
    ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (maturin, cffi)
    [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error
    
    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 1
    ╰─> See above for output.
    
    note: This error originates from a subprocess, and is likely not a problem with pip.

    I was wondering if there was something else I'm missing when I try to install the requirements for the scripts needed.

    Thanks!

Related