Libraryless. Click here for Pure Java version (3243L/19K).
scope serverSocketFactory_botCompanyEtc. import javax.net.*; import javax.net.ssl.*; static SNIKeyManager #keyManager; sS #passphrase = "botcompany"; static File #trustKeyStoreFile; static char[] #getPassphrase() { ret getChars(passphrase); } static SNIKeyManager #makeSNIKeyManager() { ret new SNIKeyManager(makeKeyManagerMap()); } static Map<S, Pair<X509KeyManager, S>> #makeKeyManagerMap() { L<File> dirs = sortByFileName(listDirsContainingFileNamed(javaxSecretDir(), "keystore.p12")); char[] passphrase = getPassphrase(); ret (Map) mapToOrderedMap(dirs, dir -> pair(fileName(dir), pair(keyManagerFromKeyStore(newFile(dir, "keystore.p12"), passphrase), fileName(dir)))); } static SSLServerSocketFactory serverSocketFactory_botCompanyEtc() ctex { trustKeyStoreFile = anyKeyStore(); if (trustKeyStoreFile == null) ret (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); KeyStore trustKeyStore = keyStoreFromFile(trustKeyStoreFile, getPassphrase()); SNIKeyManager wrappedKeyManager = makeSNIKeyManager(); keyManager = wrappedKeyManager; //wrappedKeyManager.verbose = true; TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustKeyStore); SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(new KeyManager[] {wrappedKeyManager}, trustManagerFactory.getTrustManagers(), null); ret ctx.getServerSocketFactory(); } svoid serverSocketFactory_botCompanyEtc_update() { keyManager.keyManagersByDomain = makeKeyManagerMap(); } end scope
Began life as a copy of #1024328
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028045 |
Snippet name: | serverSocketFactory_botCompanyEtc [LIVE] |
Eternal ID of this version: | #1028045/16 |
Text MD5: | c19ff73c17acf0f8365529c47e0102b6 |
Transpilation MD5: | 368e56fc3b03308923a5f1ee6b30ef19 |
Author: | stefan |
Category: | javax / https |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-23 02:39:49 |
Source code size: | 1639 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 309 / 467 |
Version history: | 15 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |