Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS 1.2 client implementation #581

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

githoniel
Copy link

base on @parthenon's PR

Tested with node offical tls server/Go offical tls server

  • fix two syntax error
  • handleCertificateRequest add support for SignatureAndHashAlgorithm
  • getClientSignature support TLS 1.2 SignatureAlgorithm using SHA256-RSA
  • createCertificateVerify add add support for SignatureAndHashAlgorithm

@davidlehn
Copy link
Member

Thanks for the updated patch. As mentioned in the other PR, there was some previous TLS 1.2 work in the 0.8 branch too. It would be good to see if any of that can be merged in as well (while dealing with the general unmerged API changes). But maybe partial support would be ok for now. Any chance of resolving the conflicts with master?

Did you have any automated testing scripts for this code?

@matianfu
Copy link

is there any plan to merge this pr recently?

@torsina
Copy link

torsina commented Mar 9, 2019

update maybe ?

@heol-files
Copy link

Hi, is this to be merged soon? TLS 1_2 would be nice to have!
Thanks for the good work!

@BurakDev
Copy link

BurakDev commented Dec 4, 2020

Hi @githoniel, what about server TLS 1.2 ?

@githoniel
Copy link
Author

Hi @githoniel, what about server TLS 1.2 ?

sorry it has been a long time. I only test client code and it works. I think it will work on server side two because they share those code

alexhorn added a commit to neuland-ingolstadt/forge that referenced this pull request Dec 22, 2021
Merge the TLS 1.2 client implementation from PR digitalbazaar#581 by githoniel
alexhorn added a commit to neuland-ingolstadt/forge that referenced this pull request Dec 22, 2021
alexhorn added a commit to neuland-ingolstadt/forge that referenced this pull request Apr 27, 2022
@ProgrammerIn-wonderland

this seems to cause a handshake failure on tls 1.2 websites with the code

const net = require('net')
const forge = require('./forge')
var socket = new net.Socket();

var client = forge.tls.createConnection({
  server: false,
  verify: function(connection, verified, depth, certs) {
    // skip verification for testing
    console.log('[tls] server certificate verified');
    return true;
  },
  connected: function(connection) {
    console.log('[tls] connected');
    // prepare some data to send (note that the string is interpreted as
    // 'binary' encoded, which works for HTTP which only uses ASCII, use
    // forge.util.encodeUtf8(str) otherwise
    client.prepare('GET / HTTP/1.1\r\nHost: github.com\r\n\r\n');
  },
  tlsDataReady: function(connection) {
    // encrypted data is ready to be sent to the server
    var data = connection.tlsData.getBytes();
    socket.write(data, 'binary'); // encoding should be 'binary'
  },
  dataReady: function(connection) {
    // clear data from the server is ready
    var data = connection.data.getBytes();
    console.log('[tls] data received from the server: ' + data);
  },
  closed: function() {
    console.log('[tls] disconnected');
  },
  error: function(connection, error) {
    throw error
  }
});

socket.on('connect', function() {
  console.log('[socket] connected');
  client.handshake();
});
socket.on('data', function(data) {
  client.process(data.toString('binary')); // encoding should be 'binary'
});
socket.on('end', function() {
  console.log('[socket] disconnected');
});

// connect to google.com
socket.connect(443, 'github.com');

// or connect to gmail's imap server (but don't send the HTTP header above)
//socket.connect(993, 'imap.gmail.com');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants