|
@@ -239,7 +239,7 @@ shared_ptr<DtlsTransport> PeerConnection::initDtlsTransport() {
|
|
throw std::logic_error("No underlying ICE transport for DTLS transport");
|
|
throw std::logic_error("No underlying ICE transport for DTLS transport");
|
|
|
|
|
|
auto certificate = mCertificate.get();
|
|
auto certificate = mCertificate.get();
|
|
- auto verifierCallback = weak_bind(&PeerConnection::checkFingerprint, this, _1);
|
|
|
|
|
|
+ auto verifierCallback = weak_bind(&PeerConnection::checkFingerprint, this, _1, fingerprintAlgorithm);
|
|
auto dtlsStateChangeCallback =
|
|
auto dtlsStateChangeCallback =
|
|
[this, weak_this = weak_from_this()](DtlsTransport::State transportState) {
|
|
[this, weak_this = weak_from_this()](DtlsTransport::State transportState) {
|
|
auto shared_this = weak_this.lock();
|
|
auto shared_this = weak_this.lock();
|
|
@@ -439,17 +439,15 @@ void PeerConnection::rollbackLocalDescription() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-bool PeerConnection::checkFingerprint(const std::string &fingerprint) const {
|
|
|
|
|
|
+bool PeerConnection::checkFingerprint(const std::string &fingerprint, const CertificateFingerprint::Algorithm &algorithm) {
|
|
std::lock_guard lock(mRemoteDescriptionMutex);
|
|
std::lock_guard lock(mRemoteDescriptionMutex);
|
|
if (!mRemoteDescription || !mRemoteDescription->fingerprint())
|
|
if (!mRemoteDescription || !mRemoteDescription->fingerprint())
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- if (config.disableFingerprintVerification)
|
|
|
|
- return true;
|
|
|
|
-
|
|
|
|
auto expectedFingerprint = mRemoteDescription->fingerprint()->value;
|
|
auto expectedFingerprint = mRemoteDescription->fingerprint()->value;
|
|
- if (expectedFingerprint == fingerprint) {
|
|
|
|
|
|
+ if (config.disableFingerprintVerification || expectedFingerprint == fingerprint) {
|
|
PLOG_VERBOSE << "Valid fingerprint \"" << fingerprint << "\"";
|
|
PLOG_VERBOSE << "Valid fingerprint \"" << fingerprint << "\"";
|
|
|
|
+ storeRemoteFingerprint(fingerprint, algorithm);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -457,6 +455,20 @@ bool PeerConnection::checkFingerprint(const std::string &fingerprint) const {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void PeerConnection::storeRemoteFingerprint(const std::string &value, const CertificateFingerprint::Algorithm &algorithm) {
|
|
|
|
+ auto iter = std::find_if(rFingerprints.begin(), rFingerprints.end(), [&](const RemoteFingerprint& existing){return existing.value == value;});
|
|
|
|
+ bool seenPreviously = iter != rFingerprints.end();
|
|
|
|
+
|
|
|
|
+ if (seenPreviously) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rFingerprints.push_back({
|
|
|
|
+ value,
|
|
|
|
+ algorithm
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
void PeerConnection::forwardMessage(message_ptr message) {
|
|
void PeerConnection::forwardMessage(message_ptr message) {
|
|
if (!message) {
|
|
if (!message) {
|
|
remoteCloseDataChannels();
|
|
remoteCloseDataChannels();
|
|
@@ -1301,6 +1313,13 @@ void PeerConnection::resetCallbacks() {
|
|
trackCallback = nullptr;
|
|
trackCallback = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+std::vector<struct RemoteFingerprint> PeerConnection::remoteFingerprints() {
|
|
|
|
+ std::vector<struct RemoteFingerprint> ret;
|
|
|
|
+ ret = rFingerprints;
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
void PeerConnection::updateTrackSsrcCache(const Description &description) {
|
|
void PeerConnection::updateTrackSsrcCache(const Description &description) {
|
|
std::unique_lock lock(mTracksMutex); // for safely writing to mTracksBySsrc
|
|
std::unique_lock lock(mTracksMutex); // for safely writing to mTracksBySsrc
|
|
|
|
|