Avatar for MaksR

MaksR

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

Most recent activity

    • 12 comments
    • 5,769 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",dn­s:"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("MIIFaTCCA1GgAwIBAgIJANSBTFhEm7iTMA­0GCSqGSIb3DQEBCwUAMEsxCzAJBgNVBAYTAlJVMQ­8wDQYDVQQIDAZSdXNzaWExEzARBgNVBAoMCkxvZ2­ljaG91c2UxFjAUBgNVBAMMDUxvZ2ljaG91c2UgQ0­EwHhcNMTYxMDA0MTkxNDEzWhcNMjYxMDAyMTkxND­EzWjBLMQswCQYDVQQGEwJSVTEPMA0GA1UECAwGUn­Vzc2lhMRMwE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SlAqeM­anYui2rw9bvqSDpkt9HTVHY+bbdH1t0DJIo7sm1u­TJefugfZC9EoIW3Qtt8ErBdpPimerN7CAQiNXuaB­h9JOafEZFUkWIdp4O9oEGkn6oHTeyhaTaZ+Na3sT­UIvCTgPRcJO8GwZHCbE27mXeN/aycTrMxFJfFvp7­F5zv8vKsbhQqkxpye2YrKeeIxOt8vA8MS/hRiHhB­CE4dRo34QV61U5R/TyaDJkHuhLPfKH6+80ZNE7fM­dSJQCfcd1ySPcCrrwmeaXf9gZ6YgtgFJjSKArYsB­v4/ChVf3U7q6bI5anUdluol69jc0lbNUzV3o/FQV­gAxcY/BM171SFEqKlriLmeAyJSBH/ovfHhGp1mIQ­iHs9KOtibS079tXALP4hORUHFmsk1rDdqSJ0GdkR­gbbEkecJLOTa5nmeriSZ6CaOcA9vPdpQxb36fZvZ­L9KfqzsraoNIOM3TDXTOJ3kCOvlF3g3t2gamJxNg­w6wSZW2R/1sRvJvXm99r3V0uUq9dMTLZ6DB2fdhz­J14a2xYwlVtvwpbibG")
        });
    
    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: 30de5c92dbfd4ddcb00fa82fed023683b8b89978­8e0e189e...
                GMT Unix Time: Dec 25, 1995 11:10:58.000000000 RTZ 2 (зима)
                Random Bytes: dbfd4ddcb00fa82fed023683b8b899788e0e189e­3b5f5a72...
            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",dn­s:"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