cocos2d / cocos2d-x-3rd-party-libs-src

Dependencies of cocos2d-x.
142 stars 169 forks source link

Enabled websockets ssl support #61

Closed igorzel closed 9 years ago

igorzel commented 9 years ago

Enabled websockets SSL support

By default SSL support is not enabled in the cocos2dx websockets 3rd party library . This change enables it. I have tested it with wss://echo.websocket.org under android, ios, mac and linux - works fine.

Added support of self signed certificates for websockets with SSL

By default it is disabled. This change allows to connect to web socket server with self signed certificate. This feature can be useful for debugging. To enable it uncomment line 15 in websockets/rules.mak. For example: with this patch you will be able to connect to wss://echo.websocket.org (wss means - connection with SSL). THIS FEATURE MUST BE DISABLED IN PRODUCTION!

Note: If you are going to use websockets library other than libwebsockets-1.3-chrome37-firefox30 you will need to check/update websocket-ssl-self-signed-cert.patch. But in any case this version is hardcoded for cocos2dx v3 - so should not be an issue.

zilongshanren commented 9 years ago

@igorzel Thanks, could you also send an PR with ssl enabled Webosckets to https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin

igorzel commented 9 years ago

@zilongshanren sure, but can you please explain what that PR should contain? Updated websockets binaries or something else?

caldelta commented 8 years ago

@igorzel I have built libwebsocket to successfully, to .a file extension on ios.

Our game use libwebsocket with SSL run OK on web browser, but when it on ios device I cant make it work!!! I fail to tell the server accept our certificate. I see those part in struct lws_context_creation_info is not set:

//    const char *ssl_cert_filepath = NULL;
//    const char *ssl_private_key_filepath = NULL;
//    const char *ssl_ca_filepath = NULL;
//    info.ssl_private_key_password = NULL;

I try to get in work by set it on runtime but not success

//    info.ssl_cert_filepath = "/Volumes/Data/cert/SSL/ssl.pem";
//    info.ssl_ca_filepath = "/Volumes/Data/cert/SSL/ca.pem";

Above file path is my client path on macOS. I dont think it work the ERROR said: _ERR: Unable to load SSL Client certs file from /Volumes/Data/cert/SSL/cuamobi.pem -- client ssl isn't going to work ERR: problem getting cert '/Volumes/Data/cert/SSL/cuamobi.pem' 33558530: error:20074002:BIO routines:FILECTRL:system lib

I dont know how to set those path for make libwebsocket on mobile device ( ios , android ) to work.

Can u navigate me some way to test or any reference to impelemnt this? Thank in advance

minggo commented 7 years ago

@igorzel i built libwebsockets as your PR suggested, and add LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT as this issue suggested, but it will crash at lws_create_context. Did you meet the issue? How did you fix it? Thanks.

Edit: i tested with iPhone6 simulator and use libwebsockets v2.1.0 and latest cocos2d-x codes in v3.14 branch.