Avatar for MaksR

MaksR

Member since Mar 2018 • Last active Nov 2018
  • 2 conversations
  • 12 comments

Most recent activity

    • 12 comments
    • 6,103 views
  • in General
    Avatar for MaksR

    in module wss.js:

    function WebSocket(host, options) {
      this.socket = null;
      options = options || {};
      this.host = host;
      this.port = options.port || 80;
      this.protocolVersion = options.protocolVersion || 13;
      this.origin = options.origin || 'Espruino';
      this.keepAlive = options.keepAlive * 1000 || 60000;
      this.masking = options.masking!==undefined ? options.masking : true;
      this.path = options.path || "/";
      this.protocol = options.protocol;
      this.lastData = "";
      this.secWebSocketKey = buildKey();
      this.cert = options.cert;
      this.key = options.key;
      this.ca = options.ca;
      this.connected = false || options.connected;
      this.headers = options.headers || {};
    }
    
    WebSocket.prototype.initializeConnection = function () {
      require("tls").connect({
        host: this.host,
        port: this.port,
        ca: this.ca,
        cert: this.cert,
        key: this.key
      }, this.onConnect.bind(this));
    };
    

    Espruino code:

    SPI3.setup({ mosi:B5, miso:C11, sck:C10 });
    var eth = require("WIZnet").connect(SPI3, D0);
    eth.setIP({ip : "192.168.1.13",subnet : "255.255.255.0",gateway:"192.168.1.1",dns:"192.168.1.1"});
    //ininodeku.herokuapp.com
    //echo.websocket.org
    var WebSocket = require('wss');
    const ws = new WebSocket('93.183.80.194', {
          path: '/time/ws',
          port: 8443,
          protocolVersion: '13',
          protocol : "chat", // optional websocket protocol
          origin: '',
         // keepAlive: 60,  // Ping Interval in seconds.
         // headers:{ some:'header', 'another-header':42 } // optional websocket headers
         ca: atob("MIIFaTCCA1GgAwIBAgIJANSBTFhEm7iTMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNVBAYTAlJVMQ8wDQYDVQQIDAZSdXNzaWExEzARBgNVBAoMCkxvZ2ljaG91c2UxFjAUBgNVBAMMDUxvZ2ljaG91c2UgQ0EwHhcNMTYxMDA0MTkxNDEzWhcNMjYxMDAyMTkxNDEzWjBLMQswCQYDVQQGEwJSVTEPMA0GA1UECAwGUnVzc2lhMRMwEQYDVQQKDApM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m1uTJefugfZC9EoIW3Qtt8ErBdpPimerN7CAQiNXuaBh9JOafEZFUkWIdp4O9oEGkn6oHTeyhaTaZ+Na3sTUIvCTgPRcJO8GwZHCbE27mXeN/aycTrMxFJfFvp7F5zv8vKsbhQqkxpye2YrKeeIxOt8vA8MS/hRiHhBCE4dRo34QV61U5R/TyaDJkHuhLPfKH6+80ZNE7fMdSJQCfcd1ySPcCrrwmeaXf9gZ6YgtgFJjSKArYsBv4/ChVf3U7q6bI5anUdluol69jc0lbNUzV3o/FQVgAxcY/BM171SFEqKlriLmeAyJSBH/ovfHhGp1mIQiHs9KOtibS079tXALP4hORUHFmsk1rDdqSJ0GdkRgbbEkecJLOTa5nmeriSZ6CaOcA9vPdpQxb36fZvZL9KfqzsraoNIOM3TDXTOJ3kCOvlF3g3t2gamJxNgw6wSZW2R/1sRvJvXm99r3V0uUq9dMTLZ6DB2fdhzJ14a2xYwlVtvwpbibG")
        });
    
    ws.on('message', function(message) {
        console.log('received: ', message);
    });
    ws.on('close', function() {
      console.log("Connection closed");
    });
    

    93.183.80.194 - real ip with Tomcat 9.0.13 and websocket (wss://93.183.80.194:8443/time/ws) + server.crt sign ca

    Espruino error: mbedtls_ssl_handshake returned -0x7780.
    Wireshark shows that the stage of certificate exchange is not coming !? (I'm not sure).
    Tomcat responds with Handshake Failure.

    Сan tomcat not like Cipher Suite: TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256 ?

    But Espruino is connected to the node.js server! (certificates are the same) , node.js client and browser connects to Tomcat.

  • in General
    Avatar for MaksR

    Handshake from Wireshark:
    Espruino - Client Hello:

       TLSv1.2 Record Layer: Handshake Protocol: Client Hello
        Content Type: Handshake (22)
        Version: TLS 1.0 (0x0301)
        Length: 49
        Handshake Protocol: Client Hello
            Handshake Type: Client Hello (1)
            Length: 45
            Version: TLS 1.2 (0x0303)
            Random: 30de5c92dbfd4ddcb00fa82fed023683b8b899788e0e189e...
                GMT Unix Time: Dec 25, 1995 11:10:58.000000000 RTZ 2 (зима)
                Random Bytes: dbfd4ddcb00fa82fed023683b8b899788e0e189e3b5f5a72...
            Session ID Length: 0
            Cipher Suites Length: 6
            Cipher Suites (3 suites)
                Cipher Suite: TLS_RSA_WITH_AES_256_CBC_SHA256 (0x003d)
                Cipher Suite: TLS_RSA_WITH_AES_128_CBC_SHA256 (0x003c)
                Cipher Suite: TLS_EMPTY_RENEGOTIATION_INFO_SCSV (0x00ff)
            Compression Methods Length: 1
            Compression Methods (1 method)
                Compression Method: null (0)
    

    Tomcat 9.13 - Handshake Failure:

       TLSv1.2 Record Layer: Alert (Level: Fatal, Description: Handshake Failure)
        Content Type: Alert (21)
        Version: TLS 1.2 (0x0303)
        Length: 2
        Alert Message
            Level: Fatal (2)
            Description: Handshake Failure (40)
    

    Maybe the problem is due to version: TLS 1.0 (0x0301)?
    or Random (GMT Unix Time)?
    or Cipher Suites ?

  • in General
    Avatar for MaksR

    Thank you!
    what to do with mbedtls_ssl_handshake returned -0x7 ?

  • in General
    Avatar for MaksR

    Board: STM32F4DISCOVERY + W5500 NET
    Library "crypto " added to firmware (mbedtls).
    SPI interface works!
    Using WS and 80 port I get a response from echo.websocket.org "hello world"
    Also I tried to connect to https server. It works!
    but

    ws = new WebSocket('wss://echo.websocket.org', {
        port: 443
    });
    

    does not work!

    may be incorrect syntax or something?

  • in General
    Avatar for MaksR

    I try so:

    SPI3.setup({ mosi:B5, miso:C11, sck:C10 });
    var eth = require("WIZnet").connect(SPI3, D0);
    eth.setIP({ip : "192.168.1.13",subnet : "255.255.255.0",gateway:"192.168.1.1",dns:"192.168.1.1"});
    
    var WebSocket = require("ws");
    const ws = new WebSocket('echo.websocket.org', {
        port: 80
    });
    
    ws.on('open', function() {
        console.log('opened');
        ws.send("hello world");
    });
    ws.on('message', function(message) {
        console.log('received: ', message);
    });
    

    how to use WSS correctly?

    ws = new WebSocket('wss://echo.websocket.org', {
        port: 443
    });
    

    ???

  • in General
    Avatar for MaksR

    Hi! help with the Websocket security client example.

  • in General
    Avatar for MaksR

    Hi,
    is it right that when irq:true, edge: 'rising' / 'falling' - does not work ?

  • in General
    Avatar for MaksR

    Thank you very much for your attention!

Actions