File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
src/main/kotlin/tech/httptoolkit/javaagent Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -3,19 +3,21 @@ package tech.httptoolkit.javaagent
3
3
import java.io.File
4
4
import java.io.FileInputStream
5
5
import java.security.KeyStore
6
- import java.security.cert.Certificate
7
6
import java.security.cert.CertificateFactory
7
+ import java.util.*
8
8
import javax.net.ssl.SSLContext
9
9
import javax.net.ssl.TrustManagerFactory
10
10
11
11
fun buildTrustManagerFactoryForCertificate (certPath : String ): TrustManagerFactory {
12
12
val certFile = File (certPath)
13
- val certificate : Certificate = CertificateFactory .getInstance(" X.509" )
14
- .generateCertificate (FileInputStream (certFile))
13
+ val certificates = CertificateFactory .getInstance(" X.509" )
14
+ .generateCertificates (FileInputStream (certFile))
15
15
16
16
val keyStore = KeyStore .getInstance(KeyStore .getDefaultType())
17
17
keyStore.load(null , null )
18
- keyStore.setCertificateEntry(" proxy-https-CA" , certificate)
18
+ for (certificate in certificates) {
19
+ keyStore.setCertificateEntry(UUID .randomUUID().toString(), certificate)
20
+ }
19
21
20
22
val trustManagerFactory = TrustManagerFactory .getInstance(TrustManagerFactory .getDefaultAlgorithm())
21
23
trustManagerFactory.init (keyStore)
You can’t perform that action at this time.
0 commit comments