Added support for conscrypt in autobench
Added conscrypt flag
Requires jar in classpath (it is not in the gradle file)
Uses reflection which may become disallowed - warnings in JDK12
package io.nats.examples.autobench;
+import java.security.Provider;
+import java.security.Security;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
+import javax.net.ssl.SSLContext;
+
import io.nats.client.Options;
/**
@@ -36,6 +40,7 @@ public class NatsAutoBench {
public static void main(String args[]) {
String server = Options.DEFAULT_URL;
boolean utf8 = false;
+ boolean conscrypt = false;
int baseMsgs = 100_000;
int latencyMsgs = 5_000;
long maxSize = 8*1024;
@@ -44,6 +49,8 @@ public class NatsAutoBench {
for (String s : args) {
if (s.equals("utf8")) {
utf8 = true;
+ } else if (s.equals("conscrypt")) {
+ conscrypt = true;
} else if (s.equals("med")) {
baseMsgs = 50_000;
latencyMsgs = 2_500;
@@ -81,6 +88,15 @@ public class NatsAutoBench {
builder.supportUTF8Subjects();
}
+ if (conscrypt) {
+ Provider provider = (Provider) Class.forName("org.conscrypt.OpenSSLProvider").newInstance();
+ Security.insertProviderAt(provider, 1);
+ }
+
+ if (server.startsWith("tls")) {
+ System.out.println("Security Provider - "+ SSLContext.getDefault().getProvider().getInfo());
+ }
+
Options connectOptions = builder.build();
List<AutoBenchmark> tests = buildTestList(baseMsgs, latencyMsgs, maxSize);
