Source:
public JnlpSlaveAgentProtocol4() throws KeyStoreException, KeyManagementException, IOException { X509Certificate identityCertificate = InstanceIdentityProvider.RSA.getCertificate(); if (identityCertificate == null) { throw new KeyStoreException("no X509Certificate found; perhaps instance-identity is missing or too old"); } RSAPrivateKey privateKey = InstanceIdentityProvider.RSA.getPrivateKey(); if (privateKey == null) { throw new KeyStoreException("no RSAPrivateKey found; perhaps instance-identity is missing or too old"); } keyStore = KeyStore.getInstance("JKS"); char[] password = "password".toCharArray(); try { keyStore.load(null, password); } catch (IOException e) { throw new IllegalStateException("Specification says this should not happen as we are not doing I/O", e); } catch (NoSuchAlgorithmException | CertificateException e) { throw new IllegalStateException("Specification says this should not happen as we are not loading keys", e); } keyStore.setKeyEntry("jenkins", privateKey, password, new X509Certificate[]{identityCertificate}); KeyManagerFactory kmf; try { kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(keyStore, password); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Specification says the default algorithm should exist", e); } catch (UnrecoverableKeyException e) { throw new IllegalStateException("The key was just inserted with this exact password", e); } trustManager = new PublicKeyMatchingX509ExtendedTrustManager(false, true); TrustManager[] trustManagers = {trustManager}; try { sslContext = SSLContext.getInstance("TLS"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Java runtime specification requires support for TLS algorithm", e); } sslContext.init(kmf.getKeyManagers(), trustManagers, null); }

Target:
public JnlpSlaveAgentProtocol4() throws KeyStoreException, KeyManagementException, IOException { X509Certificate identityCertificate = InstanceIdentityProvider.RSA.getCertificate(); if (identityCertificate == null) { throw new KeyStoreException("JENKINS-41987: no X509Certificate found; perhaps instance-identity module is missing or too old"); } RSAPrivateKey privateKey = InstanceIdentityProvider.RSA.getPrivateKey(); if (privateKey == null) { throw new KeyStoreException("JENKINS-41987: no RSAPrivateKey found; perhaps instance-identity module is missing or too old"); } keyStore = KeyStore.getInstance("JKS"); char[] password = "password".toCharArray(); try { keyStore.load(null, password); } catch (IOException e) { throw new IllegalStateException("Specification says this should not happen as we are not doing I/O", e); } catch (NoSuchAlgorithmException | CertificateException e) { throw new IllegalStateException("Specification says this should not happen as we are not loading keys", e); } keyStore.setKeyEntry("jenkins", privateKey, password, new X509Certificate[]{identityCertificate}); KeyManagerFactory kmf; try { kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(keyStore, password); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Specification says the default algorithm should exist", e); } catch (UnrecoverableKeyException e) { throw new IllegalStateException("The key was just inserted with this exact password", e); } trustManager = new PublicKeyMatchingX509ExtendedTrustManager(false, true); TrustManager[] trustManagers = {trustManager}; try { sslContext = SSLContext.getInstance("TLS"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Java runtime specification requires support for TLS algorithm", e); } sslContext.init(kmf.getKeyManagers(), trustManagers, null); }