Comments (30)
csr是证书申请文件。
alipayCertPublicKey_RSA2.crt
alipayRootCert.crt
应该是支付宝的公钥。 我猜你要用到的是alipayCertPublicKey_RSA2.crt
应用公钥RSA2048.txt
应用私钥RSA2048-敏感数据,请妥善保管.txt
这是你自己的公钥私钥
from alipay.
app_private_key_string = open("/path/to/your/private/key.pem").read()
alipay_public_key_string = open("/path/to/alipay/public/key.pem").read()
app_private_key_string == """
-----BEGIN RSA PRIVATE KEY-----
base64 encoded content
-----END RSA PRIVATE KEY-----
"""
alipay_public_key_string == """
-----BEGIN PUBLIC KEY-----
base64 encoded content
-----END PUBLIC KEY-----
"""
所以,像这些,根本没有对应的文件,能否出个教程,要怎么配置?
from alipay.
随着时间的推移, 似乎支付宝给大家提供公钥私钥的方式一直在变, 但是只要了解了公钥私钥的原理, 那么接入应该还算比较方便的
from alipay.
app_private_key_string = open("/path/to/your/private/key.pem").read()
alipay_public_key_string = open("/path/to/alipay/public/key.pem").read()
app_private_key_string == """
-----BEGIN RSA PRIVATE KEY-----
base64 encoded content
-----END RSA PRIVATE KEY-----
"""
alipay_public_key_string == """
-----BEGIN PUBLIC KEY-----
base64 encoded content
-----END PUBLIC KEY-----
"""
那这个初始化要怎么改?
from alipay.
读入证书文件即可
from alipay.
我上面提供了6个文件,不知道读取哪个
from alipay.
app开头的指的是你自己的公钥或私钥
,alipay开头的指的是支付宝的
from alipay.
app_public_key_cert_string=app_public_key_cert_string,
NameError: name 'app_public_key_cert_string' is not defined
提示这个错误,app_public_key_cert_string在哪里配置的?
from alipay.
string是从本地文件读取的。或者测试目的写死在代码里
from alipay.
from alipay import AliPay
from alipay.utils import AliPayConfig
app_private_key_string = open(r"D:\code\hgcm_sso\pay_alipay\key\web_app\alipayRootCert.crt").read()
alipay_public_key_string = open(r"D:\code\hgcm_sso\pay_alipay\key\web_app\appCertPublicKey_2021003183690727.crt").read()
alipay = AliPay(
appid="",
app_notify_url=None, # 默认回调 url
app_private_key_string=app_private_key_string,
# 支付宝的公钥,验证支付宝回传消息使用,不是你自己的公钥,
alipay_public_key_string=alipay_public_key_string,
sign_type="RSA", # RSA 或者 RSA2
debug=False, # 默认 False
verbose=False, # 输出调试数据
config=AliPayConfig(timeout=15) # 可选,请求超时时间
)
以上是代码,我现在一共拿到支付宝提供的6个文件
alipayCertPublicKey_RSA2.crt
alipayRootCert.crt
appCertPublicKey_XXXXXXXX.crt
CSR文件.csr
应用公钥RSA2048.txt
应用私钥RSA2048-敏感数据,请妥善保管.txt
都试了不行,请问
app_private_key_string
alipay_public_key_string
分别要怎么配置?
from alipay.
提示错误
Traceback (most recent call last):
File "D:\code\hgcm_sso\pay_alipay\alipay_core1.py", line 6, in
alipay = AliPay(
File "D:\Program Files\python3810\lib\site-packages\python_alipay_sdk-3.2.0-py3.8.egg\alipay_init_.py", line 93, in init
File "D:\Program Files\python3810\lib\site-packages\python_alipay_sdk-3.2.0-py3.8.egg\alipay_init_.py", line 98, in _load_key
File "D:\Program Files\python3810\lib\site-packages\Cryptodome\PublicKey\RSA.py", line 804, in import_key
return _import_keyDER(der, passphrase)
File "D:\Program Files\python3810\lib\site-packages\Cryptodome\PublicKey\RSA.py", line 719, in _import_keyDER
raise ValueError("RSA key format is not supported")
ValueError: RSA key format is not supported
from alipay.
alipay_public_key_string这个是支付宝的公钥
app_private_key_string 这个是你的私钥
from alipay.
我觉得应该分别是alipayCertPublicKey_RSA2.crt
应用私钥RSA2048-敏感数据,请妥善保管.txt
from alipay.
app_private_key_string = open(r"D:\code\hgcm_sso\pay_alipay\key\web_app\appkey.txt").read()
alipay_public_key_string = open(r"D:\code\hgcm_sso\pay_alipay\key\web_app\alipayCertPublicKey_RSA2.crt").read()
Traceback (most recent call last):
File "D:\code\hgcm_sso\pay_alipay\alipay_core1.py", line 6, in
alipay = AliPay(
File "D:\Program Files\python3810\lib\site-packages\python_alipay_sdk-3.2.0-py3.8.egg\alipay_init_.py", line 93, in init
File "D:\Program Files\python3810\lib\site-packages\python_alipay_sdk-3.2.0-py3.8.egg\alipay_init_.py", line 98, in _load_key
File "D:\Program Files\python3810\lib\site-packages\Cryptodome\PublicKey\RSA.py", line 822, in import_key
raise ValueError("RSA key format is not supported")
ValueError: RSA key format is not supported
from alipay.
https://github.com/fzlee/alipay/tree/master/tests/certs
这里有示例的证书文件。你先用这个初始化一下库。再比对自己的证书内容
from alipay.
刚咨询了官方,给的解释是官方SDK Python只有RSA2密钥加签方式,证书加签需要解析支付宝证书后去加签,具体可以参考https://blog.csdn.net/weixin_42656632/article/details/108584919
官方说证书的官方SDK都没有签名,不知道[fzleealipay是不是解决了。如果没解决,我就放弃了
from alipay.
sign_type 传rsa2试试
from alipay.
app_private_key_string = open(r"D:\code\hgcm_sso\pay_alipay\key\web_app\appkey.txt").read()
alipay_public_key_string = open(r"D:\code\hgcm_sso\pay_alipay\key\web_app\alipayCertPublicKey_RSA2.crt").read()
alipay = AliPay(
appid="",
app_notify_url=None, # 默认回调 url
app_private_key_string=app_private_key_string,
# 支付宝的公钥,验证支付宝回传消息使用,不是你自己的公钥,
alipay_public_key_string=alipay_public_key_string,
sign_type="RSA2", # RSA 或者 RSA2
debug=False, # 默认 False
verbose=False, # 输出调试数据
config=AliPayConfig(timeout=15) # 可选,请求超时时间
from alipay.
File "D:\code\hgcm_sso\pay_alipay\alipay_core1.py", line 6, in
alipay = AliPay(
File "D:\Program Files\python3810\lib\site-packages\python_alipay_sdk-3.2.0-py3.8.egg\alipay_init_.py", line 93, in init
File "D:\Program Files\python3810\lib\site-packages\python_alipay_sdk-3.2.0-py3.8.egg\alipay_init_.py", line 98, in _load_key
File "D:\Program Files\python3810\lib\site-packages\Cryptodome\PublicKey\RSA.py", line 822, in import_key
raise ValueError("RSA key format is not supported")
ValueError: RSA key format is not supported
from alipay.
我可否发东西发您邮箱,您来测试一下。是一个纯新账号,里面没数据,也没有上线。这样测试沟通成本在太高了。
from alipay.
你可以注册一个支付宝沙箱,在里面测试
from alipay.
这没啥区别啊,我这个是注册的就是新号,里面没任何数据
from alipay.
https://blog.csdn.net/weixin_42656632/article/details/108584919
在网站使用支付宝python sdk接入支付后成功后,需要实现用户提现功能,在支付宝沙箱环境下使用sdk顺利实现提现,结果转成正式环境后报错,咨询支付宝客服后告知python sdk不支持提现,原因是提现接口需要证书签名,当时就傻眼了,感觉被支付宝沙箱玩弄了
from alipay.
https://github.com/fzlee/alipay/tree/master/tests
你看看这个目录下面的代码
from alipay.
这下面 的测试代码是可以运行的,你这边的问题一般是公钥或者私钥格式有问题
from alipay.
看了。。不知道怎么用。所以支付宝提供那一堆key您看下怎么配置吧,用完我重置下秘钥就行了。没数据
from alipay.
你可以尝试了解一下证书的格式,不然就算今天解决了这个问题,以后也会在同样的问题上摔一跤
from alipay.
打开证书看看格式不对不对。此外可以学一下openssl 命令行,看看怎么查看证书里面的内容
from alipay.
"hi"[email protected];
我发到这个邮箱了,我主要是确定下alipay包是否支持证书签名模式,谢谢啦
from alipay.
- 请重新生成一下证书密钥, 因为已经发给我了, 不安全
- 根据你发的文件, 你的密钥格式是不对的, 不能被这个库读取
你可以看看这里的文档: , 需要有东西包围着支付宝给你的base64 的内容。 https://github.com/fzlee/alipay/blob/master/docs/preparation.md
from alipay.
Related Issues (20)
- 支付宝公钥已经采用证书的形式,没有提供公钥这种形式,需要自己转换?请问有没有好的解放方案么?谢谢 HOT 3
- 添加支持 alipay.fund.account.query(支付宝资金账户资产查询接口) HOT 2
- alipay.api_alipay_trade_query(out_trade_no=order_id) HOT 4
- uwsgi 无法正常返回 HOT 6
- 验证回调通知错误 HOT 4
- 没有公网ip,怎么样验证支付是否成功 HOT 2
- 能否增加aes支持 HOT 2
- ImportError: cannot import name 'Alipay' from 'alipay'
- 使用支付宝公钥 初始化AliPay时报错 binascii.Error: Incorrect padding HOT 8
- ssl依赖该升级了 HOT 3
- 您好,请问支持分账吗? HOT 11
- 是否支持证书方式的签名 HOT 10
- 应用网关是什么 HOT 3
- 3.0如何获取请求返回状态 HOT 10
- 获取用户信息怎么调用 HOT 9
- alipay支付网关已经变更了
- notify 回调消息验证失败 binascii.Error: Invalid base64-encoded string HOT 8
- ValueError: nameserver is not an IP address or valid https URL HOT 2
- 沙箱环境下调用失败(invalid-app-id)及其解决办法 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alipay.