From 0bc7fdbb35849519f7abf23ad18ccd43ac1b6a2a Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 22 Dec 2018 20:03:40 +0800 Subject: [PATCH] Always enable SRS_SSL --- trunk/auto/auto_headers.sh | 6 ------ trunk/auto/options.sh | 3 ++- trunk/src/app/srs_app_hls.cpp | 17 +---------------- trunk/src/app/srs_app_http_api.cpp | 4 ---- trunk/src/kernel/srs_kernel_ts.cpp | 5 ----- trunk/src/kernel/srs_kernel_ts.hpp | 2 -- trunk/src/libs/srs_librtmp.cpp | 5 ----- trunk/src/main/srs_main_server.cpp | 2 +- trunk/src/protocol/srs_rtmp_handshake.cpp | 20 -------------------- trunk/src/protocol/srs_rtmp_handshake.hpp | 4 ---- trunk/src/utest/srs_utest_protocol.cpp | 4 ---- trunk/src/utest/srs_utest_protocol.hpp | 2 -- 12 files changed, 4 insertions(+), 70 deletions(-) diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index adfe0251c..5dbc31423 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -103,12 +103,6 @@ else srs_undefine_macro "SRS_AUTO_HDS" $SRS_AUTO_HEADERS_H fi -if [ $SRS_SSL = YES ]; then - srs_define_macro "SRS_AUTO_SSL" $SRS_AUTO_HEADERS_H -else - srs_undefine_macro "SRS_AUTO_SSL" $SRS_AUTO_HEADERS_H -fi - if [ $SRS_MEM_WATCH = YES ]; then srs_define_macro "SRS_AUTO_MEM_WATCH" $SRS_AUTO_HEADERS_H else diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 42742a033..77f53b925 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -17,7 +17,6 @@ help=no # feature options SRS_HDS=RESERVED SRS_NGINX=RESERVED -SRS_SSL=RESERVED SRS_FFMPEG_TOOL=RESERVED SRS_INGEST=RESERVED SRS_STREAM_CASTER=RESERVED @@ -39,6 +38,7 @@ SRS_GPERF_CP=RESERVED SRS_GPROF=RESERVED # # Always enable the bellow features. +SRS_SSL=YES SRS_STAT=YES SRS_TRANSCODE=YES SRS_HTTP_CALLBACK=YES @@ -681,6 +681,7 @@ function apply_user_detail_options() { # Always enable HTTP utilies. if [ $SRS_HTTP_CORE = NO ]; then SRS_HTTP_CORE=YES; echo -e "${YELLOW}[WARN] Always enable HTTP utilies.${BLACK}"; fi + if [ $SRS_SSL = NO ]; then SRS_SSL=YES; echo -e "${YELLOW}[WARN] Always enable SSL.${BLACK}"; fi if [ $SRS_STAT = NO ]; then SRS_STAT=YES; echo -e "${YELLOW}[WARN] Always enable Statistic.${BLACK}"; fi if [ $SRS_TRANSCODE = NO ]; then SRS_TRANSCODE=YES; echo -e "${YELLOW}[WARN] Always enable Transcode.${BLACK}"; fi if [ $SRS_HTTP_CALLBACK = NO ]; then SRS_HTTP_CALLBACK=YES; echo -e "${YELLOW}[WARN] Always enable HTTP callback.${BLACK}"; fi diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index ef40588a3..81e42e0ad 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -51,10 +51,7 @@ using namespace std; #include #include #include - -#ifdef SRS_AUTO_SSL #include -#endif // drop the segment when duration of ts too small. #define SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS 100 @@ -80,10 +77,8 @@ void SrsHlsSegment::config_cipher(unsigned char* key,unsigned char* iv) { memcpy(this->iv, iv,16); -#ifdef SRS_AUTO_SSL SrsEncFileWriter* fw = (SrsEncFileWriter*)writer; fw->config_cipher(key, iv); -#endif } SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(int c, SrsRequest* r, string p, string t, string m, string mu, int s, double d) @@ -334,11 +329,7 @@ srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, } if(hls_keys) { -#ifdef SRS_AUTO_SSL writer = new SrsEncFileWriter(); -#else - writer = new SrsFileWriter(); -#endif } else { writer = new SrsFileWriter(); } @@ -656,13 +647,10 @@ srs_error_t SrsHlsMuxer::write_hls_key() { srs_error_t err = srs_success; -#ifndef SRS_AUTO_SSL if (hls_keys) { srs_warn("SSL is disabled, ignore HLS key"); } -#endif -#ifdef SRS_AUTO_SSL if (hls_keys && current->sequence_no % hls_fragments_per_key == 0) { if (RAND_bytes(key, 16) < 0) { return srs_error_wrap(err, "rand key failed."); @@ -691,7 +679,6 @@ srs_error_t SrsHlsMuxer::write_hls_key() if (hls_keys) { current->config_cipher(key, iv); } -#endif return err; } @@ -774,8 +761,7 @@ srs_error_t SrsHlsMuxer::_refresh_m3u8(string m3u8_file) // #EXT-X-DISCONTINUITY\n ss << "#EXT-X-DISCONTINUITY" << SRS_CONSTS_LF; } - -#ifdef SRS_AUTO_SSL + if(hls_keys && ((segment->sequence_no % hls_fragments_per_key) == 0)) { char hexiv[33]; srs_data_to_hex(hexiv, segment->iv, 16); @@ -792,7 +778,6 @@ srs_error_t SrsHlsMuxer::_refresh_m3u8(string m3u8_file) ss << "#EXT-X-KEY:METHOD=AES-128,URI=" << "\"" << key_path << "\",IV=0x" << hexiv << SRS_CONSTS_LF; } -#endif // "#EXTINF:4294967295.208,\n" ss.precision(3); diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 7339b25db..01fb10738 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -588,11 +588,7 @@ srs_error_t SrsGoApiFeatures::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess SrsJsonObject* features = SrsJsonAny::object(); data->set("features", features); -#ifdef SRS_AUTO_SSL features->set("ssl", SrsJsonAny::boolean(true)); -#else - features->set("ssl", SrsJsonAny::boolean(false)); -#endif features->set("hls", SrsJsonAny::boolean(true)); #ifdef SRS_AUTO_HDS features->set("hds", SrsJsonAny::boolean(true)); diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index 354ee825b..59a8ad455 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -34,11 +34,8 @@ #include using namespace std; -#ifdef SRS_AUTO_SSL #include #include -#endif - #include #include #include @@ -2616,7 +2613,6 @@ SrsVideoCodecId SrsTsContextWriter::video_codec() return vcodec; } -#ifdef SRS_AUTO_SSL SrsEncFileWriter::SrsEncFileWriter() { memset(iv,0,16); @@ -2703,7 +2699,6 @@ void SrsEncFileWriter::close() SrsFileWriter::close(); } -#endif SrsTsMessageCache::SrsTsMessageCache() { diff --git a/trunk/src/kernel/srs_kernel_ts.hpp b/trunk/src/kernel/srs_kernel_ts.hpp index 6d1830826..bd9348701 100644 --- a/trunk/src/kernel/srs_kernel_ts.hpp +++ b/trunk/src/kernel/srs_kernel_ts.hpp @@ -1572,7 +1572,6 @@ public: virtual SrsVideoCodecId video_codec(); }; -#ifdef SRS_AUTO_SSL /* * Used for HLS Encryption */ @@ -1593,7 +1592,6 @@ private: char* buf; int nb_buf; }; -#endif /** * TS messages cache, to group frames to TS message, diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index 388604607..7b24e90f5 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -653,10 +653,6 @@ int srs_rtmp_connect_server(srs_rtmp_t rtmp) int srs_rtmp_do_complex_handshake(srs_rtmp_t rtmp) { -#ifndef SRS_AUTO_SSL - // complex handshake requires ssl - return ERROR_RTMP_HS_SSL_REQUIRE; -#else int ret = ERROR_SUCCESS; srs_error_t err = srs_success; @@ -676,7 +672,6 @@ int srs_rtmp_do_complex_handshake(srs_rtmp_t rtmp) } return ret; -#endif } int srs_rtmp_do_simple_handshake(srs_rtmp_t rtmp) diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 3e4c46a23..09f6867c4 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -212,7 +212,7 @@ void show_macro_features() ss << "features"; // rch(rtmp complex handshake) - ss << ", rch:" << srs_bool2switch(SRS_AUTO_SSL_BOOL); + ss << ", rch:" << srs_bool2switch(true); ss << ", dash:" << "on"; ss << ", hls:" << srs_bool2switch(true); ss << ", hds:" << srs_bool2switch(SRS_AUTO_HDS_BOOL); diff --git a/trunk/src/protocol/srs_rtmp_handshake.cpp b/trunk/src/protocol/srs_rtmp_handshake.cpp index 817990e7e..04aae7266 100644 --- a/trunk/src/protocol/srs_rtmp_handshake.cpp +++ b/trunk/src/protocol/srs_rtmp_handshake.cpp @@ -34,8 +34,6 @@ #include #include -#ifdef SRS_AUTO_SSL - using namespace _srs_internal; // for openssl_HMACsha256 @@ -108,8 +106,6 @@ static int DH_set_length(DH *dh, long length) return 1; } -#endif - namespace _srs_internal { // 68bytes FMS key which is used to sign the sever packet. @@ -1175,13 +1171,6 @@ SrsComplexHandshake::~SrsComplexHandshake() { } -#ifndef SRS_AUTO_SSL -srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes* /*hs_bytes*/, ISrsProtocolReaderWriter* /*io*/) -{ - srs_trace("directly use simple handshake for ssl disabled."); - return srs_error_new(ERROR_RTMP_TRY_SIMPLE_HS, "try simple handshake"); -} -#else srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes* hs_bytes, ISrsProtocolReaderWriter* io) { srs_error_t err = srs_success; @@ -1265,14 +1254,7 @@ srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes* hs_byt return err; } -#endif -#ifndef SRS_AUTO_SSL -srs_error_t SrsComplexHandshake::handshake_with_server(SrsHandshakeBytes* /*hs_bytes*/, ISrsProtocolReaderWriter* /*io*/) -{ - return srs_error_new(ERROR_RTMP_TRY_SIMPLE_HS, "try simple handshake"); -} -#else srs_error_t SrsComplexHandshake::handshake_with_server(SrsHandshakeBytes* hs_bytes, ISrsProtocolReaderWriter* io) { srs_error_t err = srs_success; @@ -1346,6 +1328,4 @@ srs_error_t SrsComplexHandshake::handshake_with_server(SrsHandshakeBytes* hs_byt return err; } -#endif - diff --git a/trunk/src/protocol/srs_rtmp_handshake.hpp b/trunk/src/protocol/srs_rtmp_handshake.hpp index 5e78ad0fe..109616eee 100644 --- a/trunk/src/protocol/srs_rtmp_handshake.hpp +++ b/trunk/src/protocol/srs_rtmp_handshake.hpp @@ -31,8 +31,6 @@ class SrsComplexHandshake; class SrsHandshakeBytes; class SrsBuffer; -#ifdef SRS_AUTO_SSL - // for openssl. #include @@ -499,8 +497,6 @@ namespace _srs_internal }; } -#endif - /** * simple handshake. * user can try complex handshake first, diff --git a/trunk/src/utest/srs_utest_protocol.cpp b/trunk/src/utest/srs_utest_protocol.cpp index 80dd435c0..f0ce52eb6 100644 --- a/trunk/src/utest/srs_utest_protocol.cpp +++ b/trunk/src/utest/srs_utest_protocol.cpp @@ -214,8 +214,6 @@ srs_error_t MockBufferIO::read(void* buf, size_t size, ssize_t* nread) #ifdef ENABLE_UTEST_PROTOCOL -#ifdef SRS_AUTO_SSL - // verify the sha256 VOID TEST(ProtocolHandshakeTest, OpensslSha256) { @@ -379,8 +377,6 @@ VOID TEST(ProtocolHandshakeTest, ComplexHandshake) } } -#endif - VOID TEST(ProtocolHandshakeTest, SimpleHandshake) { uint8_t c0c1[] = { diff --git a/trunk/src/utest/srs_utest_protocol.hpp b/trunk/src/utest/srs_utest_protocol.hpp index 6b66826f5..e01da1c4e 100644 --- a/trunk/src/utest/srs_utest_protocol.hpp +++ b/trunk/src/utest/srs_utest_protocol.hpp @@ -36,9 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -#ifdef SRS_AUTO_SSL using namespace _srs_internal; -#endif #include