发送POST与https://www.hurl.it/工作,但在命令行中发送与cURL相同的POST不

时间:2014-12-29 12:16:10

标签: post curl

我正在我正在构建的网站中集成支付服务,我需要将以下POST请求发送到https://sis-t.redsys.es:25443/sis/realizarPago

curl --sslv3 -X POST \
-H 'accept: application/json' \
-H 'content-type: application/x-www-form-urlencoded' \
'https://sis-t.redsys.es:25443/sis/realizarPago' \
-d '{
    'Ds_Merchant_MerchantSignature': '8A20806C19A5C1D4E25CF26A24F19265CD32F9DE',
    'Ds_Redsys_Url': 'https://sis-t.redsys.es:25443/sis/realizarPago',
    'Ds_Merchant_Amount': 1000,
    'Ds_Merchant_ProductDescription': 'ZZSaas services',
    'Ds_Merchant_UrlOK': 'http://www.zzsaas.com/redsys/confirm',
    'Ds_Merchant_ConsumerLanguage': '001',
    'Ds_Merchant_Titular': 'Zikzakmedia SL',
    'Ds_Merchant_UrlKO': 'http://www.zzsaas.com/redsys/cancel',
    'Ds_Merchant_Currency': 978,
    'Ds_Merchant_MerchantData': None,
    'Ds_Merchant_Order': '12345ISW',
    'Ds_Merchant_TransactionType': '0',
    'Ds_Merchant_MerchantName': 'Zikzakmedia SL',
    'Ds_Merchant_MerchantCode': '000000000',
    'Ds_Merchant_Terminal': 1,
    'Ds_Merchant_MerchantURL': 'http://www.zikzakmedia.com',
}'

但该命令会返回此错误:

curl: (35) error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
curl: (6) Could not resolve host: services,
curl: (6) Could not resolve host: SL,
curl: (3) [globbing] unmatched close brace/bracket in column 164

- sslv3更改为--sslv2 我得到:

curl: (4) OpenSSL was built without SSLv2 support
curl: (6) Could not resolve host: services,
curl: (6) Could not resolve host: SL,
curl: (3) [globbing] unmatched close brace/bracket in column 164

- sslv3更改为--tlsv1 我在等待60秒后得到此信息:

curl: (35) Unknown SSL protocol error in connection to sis-t.redsys.es:25443 
curl: (6) Could not resolve host: services,
curl: (6) Could not resolve host: SL,
curl: (3) [globbing] unmatched close brace/bracket in column 164

删除--sslv3 我在等待60秒后得到这个:

curl: (35) Unknown SSL protocol error in connection to sis-t.redsys.es:25443 
curl: (6) Could not resolve host: services,
curl: (6) Could not resolve host: SL,
curl: (3) [globbing] unmatched close brace/bracket in column 164

我也尝试了以下命令

curl -v https://sis-t.redsys.es:25443/sis/realizarPago

我得到了

* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to sis-t.redsys.es:25443

奇怪的是,使用webapp https://www.hurl.it/发出请求会返回正确的响应。

1 个答案:

答案 0 :(得分:0)

我的curl版本7.39.0在不使用任何ssl / tls选项时工作正常并显示SSL connection using TLSv1.0 / AES128-SHA。除此之外,您的数据包含嵌套引号,实际上包含JSON数据而不是www-form-urlencoded数据;这是一个经过纠正和优化的命令行:

curl \
-H 'accept: application/json' \
-H 'content-type: application/json' \
https://sis-t.redsys.es:25443/sis/realizarPago \
-d '{
    "Ds_Merchant_MerchantSignature": "8A20806C19A5C1D4E25CF26A24F19265CD32F9DE",
    "Ds_Redsys_Url": "https://sis-t.redsys.es:25443/sis/realizarPago",
    "Ds_Merchant_Amount": 1000,
    "Ds_Merchant_ProductDescription": "ZZSaas services",
    "Ds_Merchant_UrlOK": "http://www.zzsaas.com/redsys/confirm",
    "Ds_Merchant_ConsumerLanguage": "001",
    "Ds_Merchant_Titular": "Zikzakmedia SL",
    "Ds_Merchant_UrlKO": "http://www.zzsaas.com/redsys/cancel",
    "Ds_Merchant_Currency": 978,
    "Ds_Merchant_MerchantData": None,
    "Ds_Merchant_Order": "12345ISW",
    "Ds_Merchant_TransactionType": "0",
    "Ds_Merchant_MerchantName": "Zikzakmedia SL",
    "Ds_Merchant_MerchantCode": "000000000",
    "Ds_Merchant_Terminal": 1,
    "Ds_Merchant_MerchantURL": "http://www.zikzakmedia.com"
}'