最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SSLv3 error when sending a request to a endpoint - Stack Overflow

programmeradmin4浏览0评论

I am attempting to request data from an endpoint however I am currently getting the following error. Any ideas how it can be resolved.

REQUEST: Error: write EPROTO 140735243141888:error:140943F2:SSL routines:SSL3_READ_BYTES:sslv3 alert unexpected message:../deps/openssl/openssl/ssl/s3_pkt.c:1289:SSL alert number 10

var cert = '{location to my certificate}'
var key = '{location to my key}'

var fs = require('fs')
    , request = require('request');

function authCallback (error, response, body) {
  if (!error && response.statusCode == 200) {
  console.log(response.headers);
  } else {
  console.error("REQUEST: "+error)
 };
}

var options = {
url: '',
agentOptions: {
    cert: fs.readFileSync(cert),
    key: fs.readFileSync(key),
    securityOptions: 'SSL_OP_NO_SSLv3'
 }
}

request.get(options, authCallback);

Many Thanks

I am attempting to request data from an endpoint however I am currently getting the following error. Any ideas how it can be resolved.

REQUEST: Error: write EPROTO 140735243141888:error:140943F2:SSL routines:SSL3_READ_BYTES:sslv3 alert unexpected message:../deps/openssl/openssl/ssl/s3_pkt.c:1289:SSL alert number 10

var cert = '{location to my certificate}'
var key = '{location to my key}'

var fs = require('fs')
    , request = require('request');

function authCallback (error, response, body) {
  if (!error && response.statusCode == 200) {
  console.log(response.headers);
  } else {
  console.error("REQUEST: "+error)
 };
}

var options = {
url: 'https://some.endpoint.co.uk',
agentOptions: {
    cert: fs.readFileSync(cert),
    key: fs.readFileSync(key),
    securityOptions: 'SSL_OP_NO_SSLv3'
 }
}

request.get(options, authCallback);

Many Thanks

Share Improve this question asked Aug 3, 2015 at 15:28 Akif TahirAkif Tahir 1713 silver badges14 bronze badges 5
  • Did you try also setting secureProtocol: 'TLSv1_method' on your agentOptions object? – mscdex Commented Aug 3, 2015 at 16:50
  • Thanks @mscdex I haven't tried that. I'll give that a go. Thank you – Akif Tahir Commented Aug 4, 2015 at 9:44
  • Is the error message different after that addition or no? If it is, what does it say? – mscdex Commented Aug 4, 2015 at 15:02
  • Hi, the message is the same. I need to use TLS version 1.2 which it is already defaulting to by the output gathered from wireshark. – Akif Tahir Commented Aug 4, 2015 at 15:07
  • @AkifTahir is there any update? i am facing with this error as well. How did you solved the problem please? – Alex Commented Dec 7, 2018 at 21:54
Add a ment  | 

3 Answers 3

Reset to default 2

My problem was similar but solution is different

FetchError: request to https://test-bdo.mos.gov.pl/api/WasteRegister/WasteTransferCard/v1/Kpo/receiver/search failed, reason: write EPROTO 140695301860680:error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 80

For some reason none of SSL related fixes solved my problem. I used some public API and problem only existed for some endpoints, so it was even more confusing.

The solution

What I did wrong - I passed headers from frontend to the backend and forwarded them to the API. Browser adds many headers, which were unnecessary here. When I limited headers to Authorization and Content-Type headers problem disappeared.

If you are using node 8 try adding this line:

require("tls").DEFAULT_ECDH_CURVE = "auto"

I am using npm urllib and mented out the following line and then the problem was solved.

options.secureOptions = require('constants').SSL_OP_NO_TLSv1_2;
发布评论

评论列表(0)

  1. 暂无评论