java - Jetty Websocket connection - ignore self signed certs -
is there way (other opening browser , accepting self signed certificate) tell jetty websockets ignore self signed certificate errors when opening websocket connections? have verified code works in environment valid certificate exists, definately related using self signed certs in other environments.
public static void main(string[] args) { string desturi = "wss://example.ws.uri.com"; if (args.length > 0) { desturi = args[0]; } sslcontextfactory sslcontextfactory = new sslcontextfactory(); websocketclient client = new websocketclient(sslcontextfactory); simpleechosocket socket = new simpleechosocket(); try { client.start(); uri echouri = new uri(desturi); clientupgraderequest request = new clientupgraderequest(); client.connect(socket, echouri, request); system.out.printf("connecting : %s%n", echouri); socket.awaitclose(5, timeunit.seconds); } catch (throwable t) { t.printstacktrace(); } { try { client.stop(); } catch (exception e) { e.printstacktrace(); } } }
you can tell sslcontextfactory not validate certificates
sslcontextfactory sec = new sslcontextfactory(); sec.setvalidatecerts(false);
Comments
Post a Comment