Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid private key error when running fake-switches on centos8 #162

Open
ansiblejunky opened this issue Apr 17, 2021 · 1 comment
Open

Comments

@ansiblejunky
Copy link

ansiblejunky commented Apr 17, 2021

Getting the following error with python 3.8 and pip install of fake-switches. Not sure what the problem might be.

[root@lab bin]# fake-switches
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.8.2/bin/fake-switches", line 10, in <module>
    sys.exit(main())
  File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/fake_switches/cmd/main.py", line 39, in main
    ssh_service.hook_to_reactor(reactor)
  File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/fake_switches/transports/ssh_service.py", line 121, in hook_to_reactor
    b'ssh-rsa': keys.Key.fromString(data=host_private_key.encode())}
  File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/twisted/conch/ssh/keys.py", line 199, in fromString
    return method(data, passphrase)
  File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/twisted/conch/ssh/keys.py", line 442, in _fromString_PRIVATE_OPENSSH
    rsa.RSAPrivateNumbers(
  File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 367, in private_key
    return backend.load_rsa_private_numbers(self)
  File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 602, in load_rsa_private_numbers
    return _RSAPrivateKey(self, rsa_cdata, evp_pkey)
  File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 389, in __init__
    raise ValueError("Invalid private key", errors)
ValueError: ('Invalid private key', [_OpenSSLErrorWithText(code=67764348, lib=4, func=160, reason=124, reason_text=b'error:040A007C:rsa routines:RSA_check_key_ex:dmp1 not congruent to d'), _OpenSSLErrorWithText(code=67764349, lib=4, func=160, reason=125, reason_text=b'error:040A007D:rsa routines:RSA_check_key_ex:dmq1 not congruent to d'), _OpenSSLErrorWithText(code=67764350, lib=4, func=160, reason=126, reason_text=b'error:040A007E:rsa routines:RSA_check_key_ex:iqmp not inverse of q')])

pip installs..

[root@lab bin]# pip list
Package        Version
-------------- -------
appdirs        1.4.4
cffi           1.14.5
constantly     15.1.0
cryptography   3.4.7
fake-switches  1.3.9
incremental    21.3.0
lxml           4.6.3
netaddr        0.8.0
pip            19.2.3
pyasn1         0.4.8
pycparser      2.20
setuptools     41.2.0
tftpy          0.8.0
Twisted        16.6.0
zope.interface 5.4.0
@ansiblejunky
Copy link
Author

It appears the problem was the cryptography version. I downgraded to version 3.0 and it works now.
pip install cryptography==3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant