Skip to content

Instantly share code, notes, and snippets.

@tjfontaine
Last active December 24, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjfontaine/6817182 to your computer and use it in GitHub Desktop.
Save tjfontaine/6817182 to your computer and use it in GitHub Desktop.
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var assert = require('assert');
try {
var crypto = require('crypto');
var tls = require('tls');
} catch (e) {
console.log('Not compiled with OPENSSL support.');
process.exit();
}
crypto.DEFAULT_ENCODING = 'buffer';
var fs = require('fs');
var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
var options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
var canSend = true;
var server = tls.Server(options, function(socket) {
process.nextTick(function() {
console.log('sending');
socket.destroy();
verify();
});
});
var client;
function verify() {
console.log('verify');
var verified = crypto.createVerify('RSA-SHA1')
.update('Test')
.verify(certPem, 'asdfasdfas', 'base64');
}
server.listen(common.PORT, function() {
client = tls.connect({
port: common.PORT,
rejectUnauthorized: false
}, function() {
verify();
}).on('data', function(data) {
console.log(data);
}).on('error', function(err) {
throw err;
}).on('close', function() {
server.close();
}).resume();
});
server.unref();
@tjfontaine
Copy link
Author

Error: 140735256580480:error:04091077:rsa routines:INT_RSA_VERIFY:wrong signature length:../deps/openssl/openssl/crypto/rsa/rsa_sign.c:158:

    at CleartextStream._pusher (tls.js:674:24)
    at SlabBuffer.use (tls.js:217:18)
    at CleartextStream.CryptoStream._push (tls.js:501:33)
    at SecurePair.cycle (tls.js:898:20)
    at SecurePair.cycle (tls.js:913:10)
    at EncryptedStream.CryptoStream.write (tls.js:285:13)
    at Socket.ondata (stream.js:38:26)
    at Socket.EventEmitter.emit (events.js:96:17)
    at TCP.onread (net.js:397:14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment