Skip to content

Commit bd7e383

Browse files
author
Kevin Burke
committed
Force negotiation using TLSv1.0
As of 3/22/2016, the eBay API has several servers that can only negotiate TLS v1.0 sessions, and several servers that can negotiate TLS v1.0, v1.1 and v1.2. Node/OpenSSL get confused by this, and occasionally attempt to parse a v1.2 response using TLS v1.0 and vice versa. The error you get back from the request looks something like this: ``` { [Error: write EPROTO 140113357338496:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:../deps/openssl/openssl/ssl/s3_pkt.c:362: ] code: 'EPROTO', errno: 'EPROTO', syscall: 'write' } ``` As far as I can tell, this isn't patched yet, in Node or OpenSSL. But setting the following options forces all connections to be negotiated with TLS v1.0, effectively fixing the issue. More reading: aws/aws-sdk-js#862 nodejs/node#3692 https://www.ssllabs.com/ssltest/analyze.html?d=api.ebay.com If you know anyone at eBay, please tell them it's a) unacceptable to have servers that can only negotiate TLS v1.0, and b) unacceptable to have a SSL certificate that was signed with SHA1, and they should upgrade both things.
1 parent dc3c454 commit bd7e383

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

lib/xml-request.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,31 @@ exports.xmlRequest = function(options, callback) {
105105
options.reqOptions = _.extend({
106106
url: buildRequestUrl(options),
107107
body: buildXmlInput(options),
108+
// As of 3/22/2016, the eBay API has several servers that can only
109+
// negotiate TLS v1.0 sessions, and several servers that can negotiate TLS
110+
// v1.0, v1.1 and v1.2. Node/OpenSSL get confused by this, and occasionally
111+
// attempt to parse a v1.2 response using TLS v1.0 and vice versa. The
112+
// error you get back from the request looks something like this:
113+
//
114+
// { [Error: write EPROTO 140113357338496:error:1408F10B:SSL
115+
// routines:SSL3_GET_RECORD:wrong version number:../deps/openssl/openssl/ssl/s3_pkt.c:362:
116+
// ] code: 'EPROTO',
117+
// errno: 'EPROTO',
118+
// syscall: 'write' }
119+
//
120+
// As far as I can tell, this isn't patched yet, in Node or OpenSSL. But
121+
// setting the following options forces all connections to be negotiated
122+
// with TLS v1.0, effectively fixing the issue.
123+
//
124+
// More reading:
125+
//
126+
// https://github.com/aws/aws-sdk-js/issues/862
127+
// https://github.com/nodejs/node/issues/3692
128+
// https://www.ssllabs.com/ssltest/analyze.html?d=api.ebay.com
129+
agentOptions: {
130+
ciphers: 'ALL',
131+
secureProtocol: 'TLSv1_method',
132+
},
108133
}, options.reqOptions);
109134

110135
debug('XML request options', options.reqOptions);

test/xml-request.test.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require('./helpers');
22

33
var
44
request = require('request'),
5-
ebay = require('../index')
5+
ebay = require('../index'),
66
xmlRequest = ebay.xmlRequest;
77

88
describe('XML requests', function() {
@@ -53,9 +53,13 @@ describe('XML requests', function() {
5353
body: '<?xml version="1.0" encoding="UTF-8"?>\n' +
5454
'<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">\n' +
5555
' <ItemID>123456</ItemID>\n' +
56-
'</GetSingleItemRequest>'
56+
'</GetSingleItemRequest>',
57+
agentOptions: {
58+
ciphers: 'ALL',
59+
secureProtocol: 'TLSv1_method',
60+
},
5761
});
58-
})
62+
});
5963
});
6064

6165

@@ -84,7 +88,7 @@ describe('XML requests', function() {
8488
' <ItemID>345678</ItemID>\n' +
8589
'</GetMultipleItemsRequest>'
8690
);
87-
})
91+
});
8892
});
8993

9094

@@ -177,7 +181,11 @@ describe('XML requests', function() {
177181
' <paginationInput>\n' +
178182
' <entriesPerPage>5</entriesPerPage>\n' +
179183
' </paginationInput>\n' +
180-
'</findItemsByKeywordsRequest>'
184+
'</findItemsByKeywordsRequest>',
185+
agentOptions: {
186+
ciphers: 'ALL',
187+
secureProtocol: 'TLSv1_method',
188+
},
181189
});
182190
});
183191

@@ -215,7 +223,7 @@ describe('XML requests', function() {
215223
' </ItemTransactionIDArray>\n' +
216224
'</GetOrderTransactionsRequest>'
217225
);
218-
})
226+
});
219227
});
220228

221229
});
@@ -291,7 +299,7 @@ describe('XML requests', function() {
291299
expect(data).to.be.ok;
292300
expect(data).to.have.property('Ack', 'Failure');
293301
expect(data).to.have.property('Orders').that.is.instanceof(Array);
294-
})
302+
});
295303
});
296304

297305

@@ -335,7 +343,7 @@ describe('XML requests', function() {
335343
expect(data).to.be.ok;
336344
expect(data).to.have.property('Ack', 'Warning');
337345
expect(data).to.have.property('Orders').that.is.instanceof(Array);
338-
})
346+
});
339347
});
340348

341349

@@ -379,7 +387,7 @@ describe('XML requests', function() {
379387

380388
it('throws an EbayClientError', function() {
381389
expect(err).to.be.an.instanceOf(ebay.EbayClientError);
382-
})
390+
});
383391
});
384392

385393
describe('non-200 response code', function() {
@@ -404,7 +412,7 @@ describe('XML requests', function() {
404412
it('throws an EbayClientError', function() {
405413
expect(err).to.be.an.instanceOf(ebay.EbayClientError);
406414
expect(err.message).to.match(/503/);
407-
})
415+
});
408416
});
409417

410418
describe('other client error', function() {
@@ -432,8 +440,8 @@ describe('XML requests', function() {
432440
it('throws an EbayClientError', function() {
433441
expect(err).to.be.an.instanceOf(ebay.EbayClientError);
434442
expect(err.message).to.match(/Boo/);
435-
})
443+
});
436444

437445
});
438-
})
446+
});
439447
});

0 commit comments

Comments
 (0)