Ignore reported pairing state if pinned cert is not found

This commit is contained in:
Cameron Gutman 2019-07-05 19:40:11 -07:00
parent a1b58ab2fc
commit f7bfa63145
2 changed files with 14 additions and 21 deletions

View File

@ -256,13 +256,9 @@ public class NvHTTP {
// This may be null, but that's okay // This may be null, but that's okay
details.remoteAddress = getXmlString(serverInfo, "ExternalIP"); details.remoteAddress = getXmlString(serverInfo, "ExternalIP");
try { // This has some extra logic to always report unpaired if the pinned cert isn't there
details.pairState = Integer.parseInt(getXmlString(serverInfo, "PairStatus")) == 1 ? details.pairState = getPairState(serverInfo);
PairState.PAIRED : PairState.NOT_PAIRED;
} catch (NumberFormatException e) {
details.pairState = PairState.FAILED;
}
try { try {
details.runningGameId = getCurrentGame(serverInfo); details.runningGameId = getCurrentGame(serverInfo);
@ -362,11 +358,20 @@ public class NvHTTP {
} }
public PairingManager.PairState getPairState() throws IOException, XmlPullParserException { public PairingManager.PairState getPairState() throws IOException, XmlPullParserException {
return pm.getPairState(getServerInfo()); return getPairState(getServerInfo());
} }
public PairingManager.PairState getPairState(String serverInfo) throws IOException, XmlPullParserException { public PairingManager.PairState getPairState(String serverInfo) throws IOException, XmlPullParserException {
return pm.getPairState(serverInfo); // If we don't have a server cert, we can't be paired even if the host thinks we are
if (serverCert == null) {
return PairState.NOT_PAIRED;
}
if (!NvHTTP.getXmlString(serverInfo, "PairStatus").equals("1")) {
return PairState.NOT_PAIRED;
}
return PairState.PAIRED;
} }
public long getMaxLumaPixelsH264(String serverInfo) throws XmlPullParserException, IOException { public long getMaxLumaPixelsH264(String serverInfo) throws XmlPullParserException, IOException {

View File

@ -1,11 +1,7 @@
package com.limelight.nvstream.http; package com.limelight.nvstream.http;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.ShortBufferException;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
@ -177,14 +173,6 @@ public class PairingManager {
r.nextInt(10), r.nextInt(10), r.nextInt(10), r.nextInt(10),
r.nextInt(10), r.nextInt(10)); r.nextInt(10), r.nextInt(10));
} }
public PairState getPairState(String serverInfo) throws IOException, XmlPullParserException {
if (!NvHTTP.getXmlString(serverInfo, "PairStatus").equals("1")) {
return PairState.NOT_PAIRED;
}
return PairState.PAIRED;
}
public X509Certificate getPairedCert() { public X509Certificate getPairedCert() {
return serverCert; return serverCert;