|
@@ -234,12 +234,14 @@ shared_ptr<DtlsTransport> PeerConnection::initDtlsTransport() {
|
|
fingerprintAlgorithm = remote->fingerprint()->algorithm;
|
|
fingerprintAlgorithm = remote->fingerprint()->algorithm;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ mRemoteFingerprintAlgorithm = fingerprintAlgorithm;
|
|
|
|
+
|
|
auto lower = std::atomic_load(&mIceTransport);
|
|
auto lower = std::atomic_load(&mIceTransport);
|
|
if (!lower)
|
|
if (!lower)
|
|
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, fingerprintAlgorithm);
|
|
|
|
|
|
+ auto verifierCallback = weak_bind(&PeerConnection::checkFingerprint, this, _1);
|
|
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,15 +441,21 @@ void PeerConnection::rollbackLocalDescription() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-bool PeerConnection::checkFingerprint(const std::string &fingerprint, const CertificateFingerprint::Algorithm &algorithm) {
|
|
|
|
|
|
+bool PeerConnection::checkFingerprint(const std::string &fingerprint) {
|
|
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) {
|
|
|
|
+ PLOG_VERBOSE << "Skipping fingerprint validation";
|
|
|
|
+ mRemoteFingerprint = fingerprint;
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
auto expectedFingerprint = mRemoteDescription->fingerprint()->value;
|
|
auto expectedFingerprint = mRemoteDescription->fingerprint()->value;
|
|
- if (config.disableFingerprintVerification || expectedFingerprint == fingerprint) {
|
|
|
|
|
|
+ if (expectedFingerprint == fingerprint) {
|
|
PLOG_VERBOSE << "Valid fingerprint \"" << fingerprint << "\"";
|
|
PLOG_VERBOSE << "Valid fingerprint \"" << fingerprint << "\"";
|
|
- storeRemoteFingerprint(fingerprint, algorithm);
|
|
|
|
|
|
+ mRemoteFingerprint = fingerprint;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -455,20 +463,6 @@ bool PeerConnection::checkFingerprint(const std::string &fingerprint, const Cert
|
|
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();
|
|
@@ -1313,11 +1307,11 @@ void PeerConnection::resetCallbacks() {
|
|
trackCallback = nullptr;
|
|
trackCallback = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
-std::vector<struct RemoteFingerprint> PeerConnection::remoteFingerprints() {
|
|
|
|
- std::vector<struct RemoteFingerprint> ret;
|
|
|
|
- ret = rFingerprints;
|
|
|
|
-
|
|
|
|
- return ret;
|
|
|
|
|
|
+CertificateFingerprint PeerConnection::remoteFingerprint() {
|
|
|
|
+ if (mRemoteFingerprint)
|
|
|
|
+ return {CertificateFingerprint{mRemoteFingerprintAlgorithm, *mRemoteFingerprint}};
|
|
|
|
+ else
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
|
|
|
|
void PeerConnection::updateTrackSsrcCache(const Description &description) {
|
|
void PeerConnection::updateTrackSsrcCache(const Description &description) {
|