Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1024328 // serverSocketFactory_botCompanyPlusAgiBlue (etc.)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2863L/19K).

import javax.net.*;
import javax.net.ssl.*;

static SNIKeyManager serverSocketFactory_botCompanyPlusAgiBlue_keyManager;

static SSLServerSocketFactory serverSocketFactory_botCompanyPlusAgiBlue() ctex {
  char[] passphrase = trim(loadSecretTextFileMandatory(#1013896, "keystore-pass")).toCharArray();

  KeyStore trustKeyStore = keyStoreFromFile(javaxSecretDir("keystore.p12"), passphrase);
  KeyManager keyManager_botCompany = keyManagerFromKeyStore(javaxSecretDir("keystore.p12"), passphrase);
  KeyManager keyManager_agiBlue = keyManagerFromKeyStore(javaxSecretDir("agi.blue/keystore.p12"), passphrase);
  KeyManager keyManager_abotsSpace = keyManagerFromKeyStore(javaxSecretDir("abots.space/keystore.p12"), passphrase);
  KeyManager keyManager_stefansOSSite = keyManagerFromKeyStore(javaxSecretDir("stefans-os.site/keystore.p12"), passphrase);

  SNIKeyManager wrappedKeyManager = new(litorderedmap(
    "botcompany.de", pair(keyManager_botCompany, "botcompany.de"),
    "agi.blue", pair(keyManager_agiBlue, "agi.blue"),
    "abots.space", pair(keyManager_abotsSpace, "abots.space"),
    "stefans-os.site", pair(keyManager_stefansOSSite, "stefans-os.site"),
    "zttnn.me", pair(keyManagerFromKeyStore(javaxSecretDir("zttnn.me/keystore.p12"), passphrase), "zttnn.me")));
  serverSocketFactory_botCompanyPlusAgiBlue_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();
}

html {
  ret "It works!";
}

Author comment

Began life as a copy of #1024325

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1024328
Snippet name: serverSocketFactory_botCompanyPlusAgiBlue (etc.)
Eternal ID of this version: #1024328/11
Text MD5: 13802c1a9663252ee93c8dfb1d4c29fd
Transpilation MD5: 600bd922695ea74c2fb13e2011e18540
Author: stefan
Category: javax / https
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-07 02:06:23
Source code size: 1808 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 244 / 369
Version history: 10 change(s)
Referenced in: [show references]