提交 3dff71d2 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

DtlsTransport: use random subject for auto-generated certificates (should fix #127)

上级 e9382bf9
...@@ -134,6 +134,8 @@ namespace RTC ...@@ -134,6 +134,8 @@ namespace RTC
RSA* rsaKey{ nullptr }; RSA* rsaKey{ nullptr };
int numBits{ 1024 }; int numBits{ 1024 };
X509_NAME* certName{ nullptr }; X509_NAME* certName{ nullptr };
std::string subject =
std::string("mediasoup") + std::to_string(Utils::Crypto::GetRandomUInt(100000, 999999));
// Create a big number object. // Create a big number object.
bne = BN_new(); bne = BN_new();
...@@ -219,9 +221,9 @@ namespace RTC ...@@ -219,9 +221,9 @@ namespace RTC
goto error; goto error;
} }
X509_NAME_add_entry_by_txt( X509_NAME_add_entry_by_txt(
certName, "O", MBSTRING_ASC, reinterpret_cast<const uint8_t*>("mediasoup"), -1, -1, 0); certName, "O", MBSTRING_ASC, reinterpret_cast<const uint8_t*>(subject.c_str()), -1, -1, 0);
X509_NAME_add_entry_by_txt( X509_NAME_add_entry_by_txt(
certName, "CN", MBSTRING_ASC, reinterpret_cast<const uint8_t*>("mediasoup"), -1, -1, 0); certName, "CN", MBSTRING_ASC, reinterpret_cast<const uint8_t*>(subject.c_str()), -1, -1, 0);
// It is self-signed so set the issuer name to be the same as the subject. // It is self-signed so set the issuer name to be the same as the subject.
ret = X509_set_issuer_name(DtlsTransport::certificate, certName); ret = X509_set_issuer_name(DtlsTransport::certificate, certName);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论