精华内容
下载资源
问答
  • SSL Websocket

    2020-11-29 02:00:26
    <div><p>Is it possible to make an SSL websocket server with this lib?</p><p>该提问来源于开源项目:me-no-dev/ESPAsyncWebServer</p></div>
  • <div><p>Please add sample code that illustrates how to use the SSL WebSocket client to connect and send/receive messages.</p><p>该提问来源于开源项目:boostorg/beast</p></div>
  • SSL websocket connection

    2020-11-23 02:12:23
    <p>I installed Kaldi Gstreamer Server and Kaljurand dictate.js client and it works ok only on Firefox without the SSL certificate. Then I installed a certificate on my machine and I modified on the ...
  • SSL websocket server

    2021-01-07 11:18:31
    m trying to use beast with SSL to write a Websocket server. The code is in below URL. It compiles OK but I can not make a ...
  • <div><p>My server uses a Beast SSL websocket with all async_* APIs wrapped with an explicit strand (though for right now I'm only running with one thread). My test client just uses the synchronous...
  • m trying to establish a connection to a SSL websocket service <p>I'm trying to accept whatever certificate server sends to me ... I just want to connect regardless of certificate <p>I'm always...
  • Ssl websocket client patch

    2021-01-11 05:51:35
    <div><p>I managed to get the ssl web socket client working by passing the io_service to on_tls_init. Also some constants where undefined on linux.</p><p>该提问来源于开源项目:zaphoyd/websocketpp...
  • SSL handshake error: stream_socket_enable_crypto(): SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could be used. This could be because the server is missing an SSL certificate (local_cert cont...

    报错

    SSL handshake error: stream_socket_enable_crypto(): SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could be used. This could be because the server is missing an SSL certificate (local_cert context option)

    解决

    • 具体的解决方案
    • 在大致gawork_work.php 里面把证书的路径指定
    • 重启。

    参考资料

    展开全文
  • <p>I am currently working on a real time notification service using websocket using TLS/SSL (wss://). I have some problem for the handshake between the browser and the server. Everything works ...
  • s async_teardown() in websocket/impl/ssl.ipp. It was reached in both client and server. <p>I can send you my test programs (Actually, they're the same ones I sent you for #1012 earlier)</p><p>该...
  • SslContext sslCtx = SslContextBuilder.forServer(file, key).build(); open(sslCtx); } catch (SSLException e) { e.printStackTrace(); } private void open(SslContext sslCtx) { EventLoopGroup bossGroup ...
        

    被 Apple_Sa 的栗子坑的不行,决定自己写个教程以供未来的自己参考

    证书

    从阿里云申请证书得到如下几个文件

    clipboard.png

    需要先用 openssl.pfx 转成 .key

    openssl pkcs12 -in server.pfx -nocerts -nodes -out server.key
    

    提示需要输入密码,密码在 pfx-password.txt 文件里。
    最终需要 2149826361xxxx.pem 文件和 server.key 文件

    netty服务器

    Server.java

    File file = new File("2149826361xxxx.pem");
    File key = new File("server.key");
    try {
        SslContext sslCtx = SslContextBuilder.forServer(file, key).build();
        open(sslCtx);
    } catch (SSLException e) {
        e.printStackTrace();
    }
    private void open(SslContext sslCtx) {
        EventLoopGroup bossGroup = new NioEventLoopGroup();
        EventLoopGroup workerGroup = new NioEventLoopGroup();
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(new Initializer(sslCtx))
                    .option(ChannelOption.SO_BACKLOG, 1024)
                    .childOption(ChannelOption.SO_KEEPALIVE, true);
    
            ChannelFuture ch = b.bind(port).sync();
            ch.channel().closeFuture().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }
    }

    Initializer.java

    
    public class Initializer extends ChannelInitializer<NioSocketChannel> {
        private final SslContext sslCtx;
        public Initializer (SslContext sslCtx) {
            this.sslCtx = sslCtx;
        }
        protected void initChannel(NioSocketChannel ch) throws Exception {
            ChannelPipeline pipeline = ch.pipeline();
            pipeline.addLast(sslCtx.newHandler(ch.alloc()));
            pipeline.addLast(new HttpServerCodec());
            pipeline.addLast(new HttpObjectAggregator(65536));
            pipeline.addLast(new ChunkedWriteHandler());
            pipeline.addLast(new WebSocketServerCompressionHandler());
            pipeline.addLast(new WebSocketServerProtocolHandler("/chat", null, true, 1024 * 10));
            pipeline.addLast(new MessageToMessageDecoder<WebSocketFrame>() {
                @Override
                protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> objs) throws Exception {
                    ByteBuf buf = frame.content();
                    objs.add(buf);
                    buf.retain();
                }
            });
            pipeline.addLast(new MessageToMessageEncoder<MessageLiteOrBuilder>() {
                @Override
                protected void encode(ChannelHandlerContext ctx, MessageLiteOrBuilder msg, List<Object> out) throws Exception {
                    ByteBuf result = null;
                    if (msg instanceof MessageLite) {
                        result = wrappedBuffer(((MessageLite) msg).toByteArray());
                    }
                    if (msg instanceof MessageLite.Builder) {
                        result = wrappedBuffer(((MessageLite.Builder) msg).build().toByteArray());
                    }
                    WebSocketFrame frame = new BinaryWebSocketFrame(result);
                    out.add(frame);
                }
            });
            pipeline.addLast(new ProtobufDecoder(ReqPB.PBdata.getDefaultInstance()));
            pipeline.addLast(new ProtoHandler());
        }
    }

    ProtoHandler.java

    
    public class ProtoHandler extends SimpleChannelInboundHandler<ReqPB.PBdata> {
        private static Logger log = Logger.getLogger(ProtoHandler.class);
    
        @Override
        public void channelActive(ChannelHandlerContext ctx) throws Exception {
            super.channelActive(ctx);
        }
    
        @Override
        protected void channelRead0(ChannelHandlerContext ctx, ReqPB.PBdata msg) {
            log.info("收到消息:" + msg);
        }
        
        @Override
        public void channelInactive(ChannelHandlerContext ctx) throws Exception {
            log.info("断开链接");
            super.channelInactive(ctx);
        }
    
        @Override
        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
           log.info("链接异常");
        }
    }
    展开全文
  • 还是在那个websocket_demo的例子rebar-creator create-app websocket_demotree一下看看大概目录├── cert│ ├── cowboy-ca.crt│ ├── server.crt│ └── server.key├── src│ ├── path_helper.erl│...

    还是在那个websocket_demo的例子

    rebar-creator create-app websocket_demo

    tree一下看看大概目录

    ├── cert

    │   ├── cowboy-ca.crt

    │   ├── server.crt

    │   └── server.key

    ├── src

    │   ├── path_helper.erl

    │   ├── route_helper.erl

    │   ├── websocket_demo.app.src

    │   ├── websocket_demo_app.erl

    │   └── ws_handler.erl

    ├──static│   ├── index.html

    │   └── js

    │   └── jquery.min.js

    cert目录从cowboy的sample里面的拿过来即可,ca证书需要全部信任,浏览器得重启,具体google看看

    static目录随便弄点过来显示下https即可,这个用来测试证书有没有问题的

    直接贴代码

    path_helper.erl

    -module(path_helper).-export([get_path/1]).

    get_path(ExtraPath)->{ok,CurrentPath}=file:get_cwd(),

    Path= string:concat(CurrentPath,"/"),string:concat(Path,ExtraPath).

    route_helper.erl

    -module(route_helper).-export([get_routes/0]).

    get_routes()->StaticPath= path_helper:get_path("../static/"),

    [

    {'_', [

    {"/websocket", ws_handler, []},

    {"/static/[...]", cowboy_static, {dir, StaticPath}}

    ]}

    ].

    websocket_demo_app.erl

    -module(websocket_demo_app).-behaviour(application).-export([start/2, stop/1]).

    start(_Type, _Args)->ok=application:start(crypto),

    ok=application:start(cowlib),

    ok=application:start(ranch),

    ok=application:start(cowboy),

    CertDir= path_helper:get_path("../cert/"),

    io:format("~p~n",[CertDir]),

    Routes=route_helper:get_routes(),

    Dispatch=cowboy_router:compile(Routes),

    Port= 8080,

    TransOpts=[

    {port, Port},

    {cacertfile, CertDir++ "/cowboy-ca.crt"},

    {certfile, CertDir++ "/server.crt"},

    {keyfile, CertDir++ "/server.key"}

    ],

    ProtoOpts=[{env, [{dispatch, Dispatch}]}],

    {ok, _}= cowboy:start_https(https,100, TransOpts, ProtoOpts).

    stop(_State)->ok.

    ws_handler.erl

    -module(ws_handler).-behaviour(cowboy_websocket_handler).-export([init/3]).-export([websocket_init/3]).-export([websocket_handle/3]).-export([websocket_info/3]).-export([websocket_terminate/3]).

    init({tcp, http}, _Req, _Opts)->io:format("init ~n"),

    {upgrade, protocol, cowboy_websocket};

    init({ssl, http}, _Req, _Opts)->io:format("ssl init ~n"),

    {upgrade, protocol, cowboy_websocket}.

    websocket_init(_TransportName, Req, _Opts)->io:format("websocket_init ~n"),

    erlang:start_timer(1000, self(), <>),

    {ok, Req, undefined_state}.

    websocket_handle({text, Msg}, Req, State)->

    %% io:format("websocket_handle text ~p,~p,~p~n",[Msg,Req,State]),

    {reply, {text,<< "That's what she said!", Msg/binary >>}, Req, State};

    websocket_handle(_Data, Req, State)->

    %% io:format("websocket_handle ~p,~p,~p~n",[_Data,Req,State]),

    {ok, Req, State}.

    websocket_info({timeout, _Ref, Msg}, Req, State)->

    %io:format("websocket timeout ~n"),

    erlang:start_timer(1000, self(), <>),

    {reply, {text, Msg}, Req, State};

    websocket_info(_Info, Req, State)->io:format("websocket_info ~p,~p,~p~n",[_Info,Req,State]),

    {ok, Req, State}.

    websocket_terminate(_Reason, _Req, _State)->io:format("terminate ~n"),

    ok.

    注意,在ssl的是,init的参数

    本地websocket测试地址

    wss://loclahost:8080/websocket

    如果提示ssl错误什么的,最好先看看下面这个对不对

    注:ssl以后,访问必须以域名,不能ip。

    展开全文
  • websocket 地址'wss://hongonew.com/hone/web/websocket/';nginx 配置server {listen 443 ssl;server_name hongonew.com;ssl on;ssl_certificate **;ssl_certificate_key **;ssl_session_cache shared:S...

    websocket 地址

    'wss://hongonew.com/hone/web/websocket/';

    nginx 配置

    server {

    listen 443 ssl;

    server_name hongonew.com;

    ssl on;

    ssl_certificate **;

    ssl_certificate_key **;

    ssl_session_cache shared:SSL:1m;

    ssl_session_timeout 5m;

    ssl_ciphers HIGH:!aNULL:!MD5;

    ssl_prefer_server_ciphers on;

    location ~/hone/{

    proxy_pass http://127.0.0.1:8080;

    index dashboard index;

    #websocket额外配置开始

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection "upgrade";

    proxy_connect_timeout 60s;#l连接超时时间,不能设置太长会浪费连接资源

    proxy_read_timeout 500s;#读超时时间

    proxy_send_timeout 500s;#写超时时间

    #websocket额外配置结束

    proxy_set_header Host $http_host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_set_header X-Forwarded-Proto $scheme;

    }

    access_log logs/https_access.log;

    error_log logs/https_error.log;

    }

    展开全文
  • <p>With SSL enabled incoming websocket connections should work. <h3>Actual behavior <p>With SSL enabled incoming Websocket connections fail. <p>Since no incoming Websocket connections are being ...
  • SSL using Websocket Protocol

    2021-01-11 01:29:29
    <div><p>i used the following configuration for SSL web socket connection. <p>port 8883 protocol mqtt cafile C:\mos\certs\ca.crt keyfile C:\mos\certs\ia.key certfile C:\mos\certs\ia.crt require_...
  • <div><p>Very good and easy to construct HTTPS and WebSocket SSL client side. However, I am having difficulty making the HTTPS and WebSocket SSL server side work. Would be great if there are examples ...
  • <p>I do however have an issue when trying to connect to a SSL enabled WebSocket server. I'm running under Ubuntu 16.04 and have build the lib with -DUSE_TLS=1, and use untrusted-ca-key and ...
  • 我要开发一个交互性很强的微信小程序,但是他需要带有sslwebsocket,服务器用的是Linux系统,大概要保证100人同时在线。 目前在纠结是选择java还是python?最关键的是如何配置好SSL?
  • sslwebsocket例子

    2015-01-03 18:26:00
    还是在那个websocket_demo的例子 rebar-creator create-app websocket_demo tree一下看看大概目录 ├── cert │ ├── cowboy-ca.crt │ ├── server.crt │ └── server.key ├── src │ ...
  • 2.因为要在android上使用websocket,要求使用wss,这时候我就选择了java_websocket(http://java-websocket.org/)这个ws客户端对wss支持不好,源码中的wss client 还要使用证书。我的想法是不验证证书。将他的代码稍...
  • <p>Turning on SSL/TLS broke the P2P layer because peers expect unencrypted <code>ws://</code> protocol (not <code>wss://). <h3>How did I fix it? <p>Turning on SSL in the config file (for the node) ...
  • 阿里上买的域名, 申请了个免费ssl, 然后开始折腾,,,, 申请了ssl证书, 但是不提供 .pem 格式的下载(*/ω\*) 然后 把一堆 提供的 都下载下来了, 然后 又到网上 搜 crt/cer 等格式 转 pem格式..... 然后 看到有说 ...
  • <div><p>FEATURE REQUEST The Websocket endpoint should support SSL (WSS) preferrably with a configurable certificate.</p><p>该提问来源于开源项目:tendermint/tendermint</p></div>
  • 我的一些开发APP的朋友,开始使用WebSocket通信,后来觉得通信不够安全,想要对通信进行加密,于是自然而然地就想从ws升级到wss。在升级的过程中,就会存在旧的ws客户端与新的wss客户端同时连接到同一个服务器的情况...
  • 想在https页面下访问非sslwebsocket服务,在firefox的默认配置下已经被禁止了,需要打开设置才可访问。 As you point out in another answer, https:// to ws:// is disallowed by default on firefox. Going ...
  • 关于websocket ssl认证

    2015-05-12 01:24:09
    服务器APP之间用websocket通信,未加ssl时正常,服务器加了认证后,客户端URL改成wss:xxx:8443连接不上,求大婶指点
  • python websocket ssl错误

    千次阅读 2019-07-26 11:48:54
    import ssl ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
  • OpenSSL生成自签名SSL证书 科普:TLS、SSL、HTTPS以及证书 不少人可能听过其中的超过3个名词,但它们究竟有什么关联呢? TLS 是传输层安全协议(Transport Layer Security)的缩写,是一种对基于网络的...
  • It requires a client SSL certificate. This was a non-issue on regular computers; just requires some generating of CSRs and we sign them internally, push back the resulting cert. <p>On the iOS side, ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,937
精华内容 774
关键字:

sslwebsocket