|
@@ -10,9 +10,10 @@ import javax.net.SocketFactory;
|
|
|
import javax.net.ssl.SSLContext;
|
|
|
import javax.net.ssl.TrustManager;
|
|
|
import javax.net.ssl.TrustManagerFactory;
|
|
|
-import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.security.KeyStore;
|
|
|
import java.security.SecureRandom;
|
|
|
import java.time.Instant;
|
|
@@ -28,7 +29,7 @@ public class MqttClient {
|
|
|
private boolean connectFlag = false;
|
|
|
|
|
|
// mqtts加密连接
|
|
|
- private final boolean isSSL = true;
|
|
|
+ private final boolean isSSL = false;
|
|
|
|
|
|
/**
|
|
|
* mqtt建链
|
|
@@ -184,7 +185,7 @@ public class MqttClient {
|
|
|
|
|
|
InputStream stream = null;
|
|
|
try {
|
|
|
- stream = new FileInputStream(certPath);
|
|
|
+ stream = Files.newInputStream(Paths.get(certPath));
|
|
|
sslContext = SSLContext.getInstance("TLS");
|
|
|
KeyStore ts = KeyStore.getInstance("JKS");
|
|
|
ts.load(stream, null);
|