Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
85e698b8
提交
85e698b8
authored
5月 10, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add transport.dtlsRemoteCert
上级
ab726518
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
61 行增加
和
10 行删除
+61
-10
Transport.js
lib/Transport.js
+13
-5
DtlsTransport.h
worker/include/RTC/DtlsTransport.h
+2
-1
Transport.h
worker/include/RTC/Transport.h
+1
-1
DtlsTransport.cpp
worker/src/RTC/DtlsTransport.cpp
+42
-2
Transport.cpp
worker/src/RTC/Transport.cpp
+3
-1
没有找到文件。
lib/Transport.js
浏览文件 @
85e698b8
...
@@ -33,6 +33,7 @@ class Transport extends EventEmitter
...
@@ -33,6 +33,7 @@ class Transport extends EventEmitter
// - .type
// - .type
// - .protocol
// - .protocol
// - .tcpType
// - .tcpType
// - .iceState
// - .iceSelectedTuple
// - .iceSelectedTuple
// - .local
// - .local
// - .ip
// - .ip
...
@@ -42,7 +43,6 @@ class Transport extends EventEmitter
...
@@ -42,7 +43,6 @@ class Transport extends EventEmitter
// - .ip
// - .ip
// - .port
// - .port
// - .protocol
// - .protocol
// - .iceState
// - .dtlsLocalParameters
// - .dtlsLocalParameters
// - .role
// - .role
// - .fingerprints
// - .fingerprints
...
@@ -52,6 +52,7 @@ class Transport extends EventEmitter
...
@@ -52,6 +52,7 @@ class Transport extends EventEmitter
// - .sha-384
// - .sha-384
// - .sha-512
// - .sha-512
// - .dtlsState
// - .dtlsState
// - .dtlsRemoteCert
this
.
_data
=
data
;
this
.
_data
=
data
;
// Channel instance
// Channel instance
...
@@ -90,6 +91,8 @@ class Transport extends EventEmitter
...
@@ -90,6 +91,8 @@ class Transport extends EventEmitter
case
'dtlsstatechange'
:
case
'dtlsstatechange'
:
{
{
this
.
_data
.
dtlsState
=
data
.
dtlsState
;
this
.
_data
.
dtlsState
=
data
.
dtlsState
;
if
(
data
.
dtlsState
===
'connected'
)
this
.
_data
.
dtlsRemoteCert
=
data
.
dtlsRemoteCert
;
// Emit it to the app
// Emit it to the app
this
.
emit
(
event
,
data
.
dtlsState
);
this
.
emit
(
event
,
data
.
dtlsState
);
break
;
break
;
...
@@ -121,14 +124,14 @@ class Transport extends EventEmitter
...
@@ -121,14 +124,14 @@ class Transport extends EventEmitter
return
this
.
_data
.
iceLocalCandidates
;
return
this
.
_data
.
iceLocalCandidates
;
}
}
get
iceS
electedTupl
e
()
get
iceS
tat
e
()
{
{
return
this
.
_data
.
iceS
electedTupl
e
;
return
this
.
_data
.
iceS
tat
e
;
}
}
get
iceS
tat
e
()
get
iceS
electedTupl
e
()
{
{
return
this
.
_data
.
iceS
tat
e
;
return
this
.
_data
.
iceS
electedTupl
e
;
}
}
get
dtlsLocalParameters
()
get
dtlsLocalParameters
()
...
@@ -141,6 +144,11 @@ class Transport extends EventEmitter
...
@@ -141,6 +144,11 @@ class Transport extends EventEmitter
return
this
.
_data
.
dtlsState
;
return
this
.
_data
.
dtlsState
;
}
}
get
dtlsRemoteCert
()
{
return
this
.
_data
.
dtlsRemoteCert
;
}
/**
/**
* Close the Transport
* Close the Transport
*/
*/
...
...
worker/include/RTC/DtlsTransport.h
浏览文件 @
85e698b8
...
@@ -73,7 +73,7 @@ namespace RTC
...
@@ -73,7 +73,7 @@ namespace RTC
// DTLS has completed negotiation of a secure connection (including DTLS-SRTP
// DTLS has completed negotiation of a secure connection (including DTLS-SRTP
// and remote fingerprint verification). Outgoing media can now flow through.
// and remote fingerprint verification). Outgoing media can now flow through.
// NOTE: The caller MUST NOT call any method during this callback.
// NOTE: The caller MUST NOT call any method during this callback.
virtual
void
onDtlsConnected
(
DtlsTransport
*
dtlsTransport
,
RTC
::
SrtpSession
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
=
0
;
virtual
void
onDtlsConnected
(
DtlsTransport
*
dtlsTransport
,
RTC
::
SrtpSession
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
,
std
::
string
&
remoteCert
)
=
0
;
// The DTLS connection has been closed as the result of an error (such as a
// The DTLS connection has been closed as the result of an error (such as a
// DTLS alert or a failure to validate the remote fingerprint).
// DTLS alert or a failure to validate the remote fingerprint).
// NOTE: The caller MUST NOT call Close() during this callback.
// NOTE: The caller MUST NOT call Close() during this callback.
...
@@ -159,6 +159,7 @@ namespace RTC
...
@@ -159,6 +159,7 @@ namespace RTC
Fingerprint
remoteFingerprint
=
{
FingerprintAlgorithm
::
NONE
,
""
};
Fingerprint
remoteFingerprint
=
{
FingerprintAlgorithm
::
NONE
,
""
};
bool
handshakeDone
=
false
;
bool
handshakeDone
=
false
;
bool
handshakeDoneNow
=
false
;
bool
handshakeDoneNow
=
false
;
std
::
string
remoteCert
;
};
};
/* Inline static methods. */
/* Inline static methods. */
...
...
worker/include/RTC/Transport.h
浏览文件 @
85e698b8
...
@@ -95,7 +95,7 @@ namespace RTC
...
@@ -95,7 +95,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::DtlsTransport::Listener. */
/* Pure virtual methods inherited from RTC::DtlsTransport::Listener. */
public
:
public
:
virtual
void
onDtlsConnecting
(
DtlsTransport
*
dtlsTransport
)
override
;
virtual
void
onDtlsConnecting
(
DtlsTransport
*
dtlsTransport
)
override
;
virtual
void
onDtlsConnected
(
DtlsTransport
*
dtlsTransport
,
RTC
::
SrtpSession
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
override
;
virtual
void
onDtlsConnected
(
DtlsTransport
*
dtlsTransport
,
RTC
::
SrtpSession
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
,
std
::
string
&
remoteCert
)
override
;
virtual
void
onDtlsFailed
(
DtlsTransport
*
dtlsTransport
)
override
;
virtual
void
onDtlsFailed
(
DtlsTransport
*
dtlsTransport
)
override
;
virtual
void
onDtlsClosed
(
DtlsTransport
*
dtlsTransport
)
override
;
virtual
void
onDtlsClosed
(
DtlsTransport
*
dtlsTransport
)
override
;
virtual
void
onOutgoingDtlsData
(
RTC
::
DtlsTransport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onOutgoingDtlsData
(
RTC
::
DtlsTransport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
...
...
worker/src/RTC/DtlsTransport.cpp
浏览文件 @
85e698b8
...
@@ -999,12 +999,15 @@ namespace RTC
...
@@ -999,12 +999,15 @@ namespace RTC
MS_ABORT
(
"unknown algorithm"
);
MS_ABORT
(
"unknown algorithm"
);
}
}
// Compare the remote fingerprint with the value given via signaling.
ret
=
X509_digest
(
certificate
,
hash_function
,
binary_fingerprint
,
&
size
);
ret
=
X509_digest
(
certificate
,
hash_function
,
binary_fingerprint
,
&
size
);
X509_free
(
certificate
);
if
(
ret
==
0
)
if
(
ret
==
0
)
{
{
MS_ERROR
(
"X509_digest() failed"
);
MS_ERROR
(
"X509_digest() failed"
);
X509_free
(
certificate
);
return
false
;
return
false
;
}
}
...
@@ -1019,11 +1022,48 @@ namespace RTC
...
@@ -1019,11 +1022,48 @@ namespace RTC
{
{
MS_WARN
(
"fingerprint in the remote certificate (%s) does not match the announced one (%s)"
,
hex_fingerprint
,
this
->
remoteFingerprint
.
value
.
c_str
());
MS_WARN
(
"fingerprint in the remote certificate (%s) does not match the announced one (%s)"
,
hex_fingerprint
,
this
->
remoteFingerprint
.
value
.
c_str
());
X509_free
(
certificate
);
return
false
;
return
false
;
}
}
MS_DEBUG
(
"valid remote fingerprint"
);
MS_DEBUG
(
"valid remote fingerprint"
);
// Get the remote certificate in PEM format.
BIO
*
bio
=
BIO_new
(
BIO_s_mem
());
// Ensure the underlying BUF_MEM structure is also freed.
BIO_set_close
(
bio
,
BIO_CLOSE
);
ret
=
PEM_write_bio_X509
(
bio
,
certificate
);
if
(
ret
!=
1
)
{
LOG_OPENSSL_ERROR
(
"PEM_write_bio_X509() failed"
);
X509_free
(
certificate
);
BIO_free
(
bio
);
return
false
;
}
BUF_MEM
*
mem
;
BIO_get_mem_ptr
(
bio
,
&
mem
);
if
(
!
mem
||
!
mem
->
data
||
!
mem
->
length
)
{
LOG_OPENSSL_ERROR
(
"BIO_get_mem_ptr() failed"
);
X509_free
(
certificate
);
BIO_free
(
bio
);
return
false
;
}
this
->
remoteCert
=
std
::
string
(
mem
->
data
,
mem
->
length
);
X509_free
(
certificate
);
BIO_free
(
bio
);
return
true
;
return
true
;
}
}
...
@@ -1072,7 +1112,7 @@ namespace RTC
...
@@ -1072,7 +1112,7 @@ namespace RTC
// Set state and notify the listener.
// Set state and notify the listener.
this
->
state
=
DtlsState
::
CONNECTED
;
this
->
state
=
DtlsState
::
CONNECTED
;
this
->
listener
->
onDtlsConnected
(
this
,
srtp_profile
,
srtp_local_master_key
,
MS_SRTP_MASTER_LENGTH
,
srtp_remote_master_key
,
MS_SRTP_MASTER_LENGTH
);
this
->
listener
->
onDtlsConnected
(
this
,
srtp_profile
,
srtp_local_master_key
,
MS_SRTP_MASTER_LENGTH
,
srtp_remote_master_key
,
MS_SRTP_MASTER_LENGTH
,
this
->
remoteCert
);
}
}
inline
inline
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
85e698b8
...
@@ -989,12 +989,13 @@ namespace RTC
...
@@ -989,12 +989,13 @@ namespace RTC
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event_data
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event_data
);
}
}
void
Transport
::
onDtlsConnected
(
RTC
::
DtlsTransport
*
dtlsTransport
,
RTC
::
SrtpSession
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
void
Transport
::
onDtlsConnected
(
RTC
::
DtlsTransport
*
dtlsTransport
,
RTC
::
SrtpSession
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
,
std
::
string
&
remoteCert
)
{
{
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
v_connected
(
"connected"
);
static
const
Json
::
StaticString
v_connected
(
"connected"
);
static
const
Json
::
StaticString
k_dtlsRemoteCert
(
"dtlsRemoteCert"
);
Json
::
Value
event_data
(
Json
::
objectValue
);
Json
::
Value
event_data
(
Json
::
objectValue
);
...
@@ -1037,6 +1038,7 @@ namespace RTC
...
@@ -1037,6 +1038,7 @@ namespace RTC
// Notify.
// Notify.
event_data
[
k_dtlsState
]
=
v_connected
;
event_data
[
k_dtlsState
]
=
v_connected
;
event_data
[
k_dtlsRemoteCert
]
=
remoteCert
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event_data
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event_data
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论