after reginster Public Ed25519 key on binance, I run the example binance-signature-examples/python/ed25519_signature.py at master · binance/binance-signature-examples · GitHub, but failed with “ed25519 failed as certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)”
centos7, openssl 1.1.1d, python3.10
Does the key error?
How to debug the problem
import base64
import requests
import time
from cryptography.hazmat.primitives.serialization import load_pem_private_key
# Set up authentication
API_KEY='Yxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
PRIVATE_KEY_PATH='Private_key2.txt'
# Load the private key
# Generally we recommend using a strong password for improved security.
with open(PRIVATE_KEY_PATH, 'rb') as f:
private_key = load_pem_private_key(data=f.read(),
password=None)
# Set up the request parameters
params = {
'symbol': 'BNBUSDT',
'side': 'SELL',
'type': 'LIMIT',
'timeInForce': 'GTC',
'quantity': '1.0000000',
'price': '300.20',
}
# Timestamp the request
timestamp = int(time.time() * 1000)
params['timestamp'] = timestamp
# Sign the request
payload = '&'.join([f'{param}={value}' for param, value in params.items()])
signature = base64.b64encode(private_key.sign(payload.encode('ASCII')))
params['signature'] = signature
# Send the request
headers = {
'X-MBX-APIKEY': API_KEY,
}
response = requests.post(
'https://api.binance.com/api/v3/order',
headers=headers,
data=params,
)
print(response.json())