1 | // seems to assume same password is used for keystore as well as certificate. |
2 | // if keystore file name ends with "12", it's assumed to be in PKCS12 format. |
3 | static SSLServerSocketFactory makeSSLServerSocketFactory(File keystoreFile, S passphrase) ctex { |
4 | KeyStore keystore = KeyStore.getInstance( |
5 | endsWith(fileName(keystoreFile), "12") ? "PKCS12" |
6 | : KeyStore.getDefaultType()); |
7 | temp InputStream keystoreStream = new FileInputStream(keystoreFile); |
8 | keystore.load(keystoreStream, passphrase.toCharArray()); |
9 | TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); |
10 | trustManagerFactory.init(keystore); |
11 | KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); |
12 | keyManagerFactory.init(keystore, passphrase.toCharArray()); |
13 | SSLContext ctx = SSLContext.getInstance("TLS"); |
14 | ctx.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); |
15 | ret ctx.getServerSocketFactory(); |
16 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018506 |
Snippet name: | makeSSLServerSocketFactory |
Eternal ID of this version: | #1018506/4 |
Text MD5: | 26cb86ac0b7681d262f8f1c9c7a13b2e |
Author: | stefan |
Category: | javax / https |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-31 17:37:01 |
Source code size: | 1047 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 410 / 452 |
Version history: | 3 change(s) |
Referenced in: | [show references] |