ValueError:RSA key format is not supported(python对接支付宝RSA加密格式问题)

python3使用python-alipay-sdk对接支付宝的时候,可能会出现以下错误不支持RSA密钥格式

ERROR:

File “D:\graduation\python\lib\site-packages\alipay_init_.py”, line 96, in _load_key
self._app_private_key = RSA.importKey(content) File “D:\graduation\python\lib\site-packages\Cryptodome\PublicKey\RSA.py”,
line 781, in import_key
raise ValueError(“RSA key format is not supported”) ValueError: RSA key format is not supported [24/Oct/2020 19:58:31] “POST
/order/pay/ HTTP/1.1” 500 16412

解决办法:
把公钥和私钥的内容先读出来,然后再用读出来的内容去创建Alipay对象

        alipay = AliPay(
            appid="2016102700768234",  
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页