Skip to content

Bug: SrsHttpxConn SSL Key&Cert config problem. #4025

@suzp1984

Description

@suzp1984

Describe the bug

// Do SSL handshake if HTTPS.
if (ssl) {
srs_utime_t starttime = srs_update_system_time();
string crt_file = _srs_config->get_https_stream_ssl_cert();
string key_file = _srs_config->get_https_stream_ssl_key();
if ((err = ssl->handshake(key_file, crt_file)) != srs_success) {

SrsHttpxConn can be used as HTTP API and HTTP Server, for both plain and SSL connection. For the SSL connection, we can config the SSL key & cert in this way.

http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
https {
enabled on;
listen 8088;
key ./conf/server.key;
cert ./conf/server.crt;
}
}
http_api {
enabled on;
listen 1985;
https {
enabled on;
listen 1990;
key ./conf/server.key;
cert ./conf/server.crt;
}
}

And SrsConfig has apis to get the key & cert.

virtual std::string get_https_api_ssl_key();
virtual std::string get_https_api_ssl_cert();

virtual std::string get_https_stream_ssl_key();
virtual std::string get_https_stream_ssl_cert();

But SrsHttpxConn only calling get_https_stream_ssl_cert & get_https_stream_ssl_key even for the Https API connections.

Version
All SRS version.

To Reproduce
Steps to reproduce the behavior:

  1. config https api and https stream with different key & cert pair.
  2. boot the srs.

Expected behavior
http_api.https.key | cert should be loaded correctly.

Additional context
I found this bug when try to do #3701, found this bug and also #4024

Metadata

Metadata

Assignees

Labels

APIHTTP-API, HTTP-Callback, etc.EnglishNativeThis issue is conveyed exclusively in English.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions