2017 01 01 24 05 [nodejs] nodejs v6.9.2 does support ALPN with openssl 1.0.2j

因為看了這個網頁 https://segmentfault.com/a/1190000002757622
也跑了裡面的測試程式, 發現nodejs似乎真的沒有支援ALPN.
昨天花了很多時間, 在找方法怎麼讓nodejs支援ALPN.
甚至連openssl都換新的,重新編譯nodejs也不行.
花了很多時間,最後試著去改他的測試程式.
這才發現,原來是測試程式寫錯了.
他寫log的是npnProtocl,不是alpnProtocl,
這也難怪,他會覺得不支援alpn,因為寫錯啦!
只需要把npnProtocol 改成 alpnProtocol.
=======

     var fs = require('fs');
        var path = require('path');
        var tls = require('tls');
        tls.createServer({
          key: fs.readFileSync("example/localhost.key"),
          cert: fs.readFileSync("example/localhost.crt"),
          ALPNProtocols: ['h2', 'http/1.1','http/1.0']
        }, function(socket) {
-          console.log("s1:"+socket.npnProtocol);
+          console.log("s1:"+socket.alpnProtocol);
        }).listen(1111);
        //client
      process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
      tls.connect({ port: 1111 }, function() {          
      });
      tls.connect({ port: 1111 ,ALPNProtocols: ['h2'] }, function() {
      });
      tls.connect({ port: 1111, ALPNProtocols: ['http/1.1'] }, function() {
      });      
      tls.connect({ port: 1111, ALPNProtocols: ['http/1.0'] }, function() {
      });

=======
PS: 根據 https://tools.ietf.org/html/rfc7301,
      ALPN似乎沒有所謂的http/1.0