MCPcopy Create free account
hub / github.com/TigerVNC/tigervnc / setParam

Method setParam

java/com/tigervnc/rfb/CSecurityTLS.java:146–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144 }
145
146 private void setParam() {
147
148 if (anon) {
149 try {
150 ctx.init(null, null, null);
151 } catch(KeyManagementException e) {
152 throw new AuthFailureException(e.toString());
153 }
154 } else {
155 try {
156 TrustManager[] myTM = new TrustManager[] {
157 new MyX509TrustManager()
158 };
159 ctx.init (null, myTM, null);
160 } catch (java.security.GeneralSecurityException e) {
161 throw new AuthFailureException(e.toString());
162 }
163 }
164 SSLSocketFactory sslfactory = ctx.getSocketFactory();
165 engine = ctx.createSSLEngine(client.getServerName(),
166 client.getServerPort());
167 engine.setUseClientMode(true);
168
169 String[] supported = engine.getSupportedProtocols();
170 ArrayList<String> enabled = new ArrayList<String>();
171 for (int i = 0; i < supported.length; i++)
172 if (supported[i].matches("TLS.*"))
173 enabled.add(supported[i]);
174 engine.setEnabledProtocols(enabled.toArray(new String[0]));
175
176 if (anon) {
177 supported = engine.getSupportedCipherSuites();
178 enabled = new ArrayList<String>();
179 // prefer ECDH over DHE
180 for (int i = 0; i < supported.length; i++)
181 if (supported[i].matches("TLS_ECDH_anon.*"))
182 enabled.add(supported[i]);
183 for (int i = 0; i < supported.length; i++)
184 if (supported[i].matches("TLS_DH_anon.*"))
185 enabled.add(supported[i]);
186 engine.setEnabledCipherSuites(enabled.toArray(new String[0]));
187 } else {
188 engine.setEnabledCipherSuites(engine.getSupportedCipherSuites());
189 }
190
191 }
192
193 class MyX509TrustManager implements X509TrustManager
194 {

Callers 1

processMsgMethod · 0.95

Calls 5

getServerPortMethod · 0.80
initMethod · 0.65
addMethod · 0.65
toStringMethod · 0.45
getServerNameMethod · 0.45

Tested by

no test coverage detected