Fixes an issue which could cause the DTLS-SRTP implementation to assume the role of a DTLS server instead of a DTLS client.

cusax-fix 4941
Lyubomir Marinov 12 years ago
parent 37a20c62da
commit 1015c31539

@ -1126,12 +1126,10 @@ private boolean addDtlsAdvertisedEncryptions(
if (dtlsControl != null)
{
/*
* Jitsi Videobridge is a server-side endpoint and thus is supposed
* to have a public IP so it makes sense to start the DTLS-SRTP
* endpoint represented by this Call as a client.
*/
dtlsControl.setDtlsProtocol(DtlsControl.DTLS_CLIENT_PROTOCOL);
dtlsControl.setSetup(
peer.isInitiator()
? DtlsControl.Setup.ACTIVE
: DtlsControl.Setup.PASSIVE);
}
IceUdpTransportPacketExtension remoteTransport = channel.getTransport();

@ -2340,7 +2340,7 @@ boolean addDtlsAdvertisedEncryptions(
}
DtlsControl dtlsControl;
int dtlsProtocol;
DtlsControl.Setup setup;
if (isInitiator)
{
@ -2349,7 +2349,7 @@ boolean addDtlsAdvertisedEncryptions(
srtpControls.get(
mediaType,
SrtpControlType.DTLS_SRTP);
dtlsProtocol = DtlsControl.DTLS_SERVER_PROTOCOL;
setup = DtlsControl.Setup.PASSIVE;
}
else
{
@ -2358,12 +2358,12 @@ boolean addDtlsAdvertisedEncryptions(
srtpControls.getOrCreate(
mediaType,
SrtpControlType.DTLS_SRTP);
dtlsProtocol = DtlsControl.DTLS_CLIENT_PROTOCOL;
setup = DtlsControl.Setup.ACTIVE;
}
if (dtlsControl != null)
{
dtlsControl.setDtlsProtocol(dtlsProtocol);
dtlsControl.setRemoteFingerprints(remoteFingerprints);
dtlsControl.setSetup(setup);
removeAndCleanupOtherSrtpControls(
mediaType,
SrtpControlType.DTLS_SRTP);
@ -2531,12 +2531,12 @@ private boolean setDtlsEncryptionOnContent(
if (dtlsControl != null)
{
int dtlsProtocol
DtlsControl.Setup setup
= (remoteContent == null)
? DtlsControl.DTLS_SERVER_PROTOCOL
: DtlsControl.DTLS_CLIENT_PROTOCOL;
? DtlsControl.Setup.PASSIVE
: DtlsControl.Setup.ACTIVE;
dtlsControl.setDtlsProtocol(dtlsProtocol);
dtlsControl.setSetup(setup);
b = true;
setDtlsEncryptionOnTransport(

@ -30,12 +30,28 @@ public enum RTPLevelRelayType
*/
TRANSLATOR;
/**
* Parses a <tt>String</tt> into an <tt>RTPLevelRelayType</tt> enum value.
* The specified <tt>String</tt> to parse must be in a format as produced by
* {@link #toString()}; otherwise, the method will throw an exception.
*
* @param s the <tt>String</tt> to parse into an <tt>RTPLevelRelayType</tt>
* enum value
* @return an <tt>RTPLevelRelayType</tt> enum value on which
* <tt>toString()</tt> produces the specified <tt>s</tt>
* @throws IllegalArgumentException if none of the
* <tt>RTPLevelRelayType</tt> enum values produce the specified <tt>s</tt>
* when <tt>toString()</tt> is invoked on them
* @throws NullPointerException if <tt>s</tt> is <tt>null</tt>
*/
public static RTPLevelRelayType parseRTPLevelRelayType(String s)
{
for (RTPLevelRelayType value : RTPLevelRelayType.values())
if (s == null)
throw new NullPointerException("s");
for (RTPLevelRelayType v : values())
{
if (s.equals(value.toString()))
return value;
if (v.toString().equalsIgnoreCase(s))
return v;
}
throw new IllegalArgumentException(s);
}
@ -46,14 +62,6 @@ public static RTPLevelRelayType parseRTPLevelRelayType(String s)
@Override
public String toString()
{
switch (this)
{
case MIXER:
return "mixer";
case TRANSLATOR:
return "translator";
default:
return super.toString();
}
return name().toLowerCase();
}
}

@ -44,14 +44,8 @@ public class CallPeerMediaHandlerSipImpl
*/
private static final String DTLS_SRTP_FINGERPRINT_ATTR = "fingerprint";
private static final String DTLS_SRTP_SETUP_ACTIVE = "active";
private static final String DTLS_SRTP_SETUP_ACTPASS = "actpass";
private static final String DTLS_SRTP_SETUP_ATTR = "setup";
private static final String DTLS_SRTP_SETUP_PASSIVE = "passive";
/**
* Our class logger.
*/
@ -820,12 +814,14 @@ private boolean updateMediaDescriptionForDtls(
Vector<Attribute> attrs = localMd.getAttributes(true);
// setup
String setup
DtlsControl.Setup setup
= (remoteMd == null)
? DTLS_SRTP_SETUP_ACTPASS
: DTLS_SRTP_SETUP_ACTIVE;
? DtlsControl.Setup.ACTPASS
: DtlsControl.Setup.ACTIVE;
Attribute setupAttr
= SdpUtils.createAttribute(DTLS_SRTP_SETUP_ATTR, setup);
= SdpUtils.createAttribute(
DTLS_SRTP_SETUP_ATTR,
setup.toString());
attrs.add(setupAttr);
@ -840,12 +836,7 @@ private boolean updateMediaDescriptionForDtls(
attrs.add(fingerprintAttr);
int dtlsProtocol
= DTLS_SRTP_SETUP_ACTIVE.equals(setup)
? DtlsControl.DTLS_CLIENT_PROTOCOL
: DtlsControl.DTLS_SERVER_PROTOCOL;
dtlsControl.setDtlsProtocol(dtlsProtocol);
dtlsControl.setSetup(setup);
if (remoteMd != null) // answer
updateSrtpControlsForDtls(mediaType, localMd, remoteMd);
@ -921,11 +912,8 @@ private void updateSrtpControlsForDtls(
{
setup = null;
}
if (DTLS_SRTP_SETUP_PASSIVE.equals(setup))
{
dtlsControl.setDtlsProtocol(
DtlsControl.DTLS_CLIENT_PROTOCOL);
}
if (DtlsControl.Setup.PASSIVE.toString().equals(setup))
dtlsControl.setSetup(DtlsControl.Setup.ACTIVE);
}
// fingerprint

Loading…
Cancel
Save