Compare commits
1
Commits
6b798f3046
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b2f2da35f
|
@@ -10,6 +10,7 @@ import java.util.concurrent.TimeUnit
|
|||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import javax.net.ssl.TrustManagerFactory
|
import javax.net.ssl.TrustManagerFactory
|
||||||
|
import javax.net.ssl.X509ExtendedTrustManager
|
||||||
import javax.net.ssl.X509TrustManager
|
import javax.net.ssl.X509TrustManager
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import io.netty.util.concurrent.Future as NettyFuture
|
import io.netty.util.concurrent.Future as NettyFuture
|
||||||
@@ -74,13 +75,25 @@ class RemoteBuildCacheClient(private val profile: Configuration.Profile) : AutoC
|
|||||||
)
|
)
|
||||||
profile.tlsTruststore?.let { trustStore ->
|
profile.tlsTruststore?.let { trustStore ->
|
||||||
if (!trustStore.verifyServerCertificate) {
|
if (!trustStore.verifyServerCertificate) {
|
||||||
trustManager(object : X509TrustManager {
|
trustManager(object : X509ExtendedTrustManager() {
|
||||||
override fun checkClientTrusted(certChain: Array<out X509Certificate>, p1: String?) {
|
override fun checkClientTrusted(certChain: Array<out X509Certificate>, p1: String?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun checkClientTrusted(certChain: Array<out X509Certificate>, p1: String?, socket: java.net.Socket) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun checkClientTrusted(certChain: Array<out X509Certificate>, p1: String?, engine: javax.net.ssl.SSLEngine) {
|
||||||
|
}
|
||||||
|
|
||||||
override fun checkServerTrusted(certChain: Array<out X509Certificate>, p1: String?) {
|
override fun checkServerTrusted(certChain: Array<out X509Certificate>, p1: String?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun checkServerTrusted(certChain: Array<out X509Certificate>, p1: String?, socket: java.net.Socket) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun checkServerTrusted(certChain: Array<out X509Certificate>, p1: String?, engine: javax.net.ssl.SSLEngine) {
|
||||||
|
}
|
||||||
|
|
||||||
override fun getAcceptedIssuers() = null
|
override fun getAcceptedIssuers() = null
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import java.security.cert.X509Certificate
|
|||||||
import java.util.EnumSet
|
import java.util.EnumSet
|
||||||
import java.util.ServiceLoader
|
import java.util.ServiceLoader
|
||||||
import javax.net.ssl.TrustManagerFactory
|
import javax.net.ssl.TrustManagerFactory
|
||||||
|
import javax.net.ssl.X509ExtendedTrustManager
|
||||||
import javax.net.ssl.X509TrustManager
|
import javax.net.ssl.X509TrustManager
|
||||||
import net.woggioni.jwo.JWO
|
import net.woggioni.jwo.JWO
|
||||||
import net.woggioni.jwo.Tuple2
|
import net.woggioni.jwo.Tuple2
|
||||||
@@ -124,7 +125,7 @@ object RBCS {
|
|||||||
return keystore
|
return keystore
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTrustManager(trustStore: KeyStore?, certificateRevocationEnabled: Boolean): X509TrustManager {
|
fun getTrustManager(trustStore: KeyStore?, certificateRevocationEnabled: Boolean): X509ExtendedTrustManager {
|
||||||
return if (trustStore != null) {
|
return if (trustStore != null) {
|
||||||
val certificateFactory = CertificateFactory.getInstance("X.509")
|
val certificateFactory = CertificateFactory.getInstance("X.509")
|
||||||
val validator = CertPathValidator.getInstance("PKIX").apply {
|
val validator = CertPathValidator.getInstance("PKIX").apply {
|
||||||
@@ -136,7 +137,7 @@ object RBCS {
|
|||||||
val params = PKIXParameters(trustStore).apply {
|
val params = PKIXParameters(trustStore).apply {
|
||||||
isRevocationEnabled = certificateRevocationEnabled
|
isRevocationEnabled = certificateRevocationEnabled
|
||||||
}
|
}
|
||||||
object : X509TrustManager {
|
object : X509ExtendedTrustManager() {
|
||||||
override fun checkClientTrusted(chain: Array<out X509Certificate>, authType: String) {
|
override fun checkClientTrusted(chain: Array<out X509Certificate>, authType: String) {
|
||||||
val clientCertificateChain = certificateFactory.generateCertPath(chain.toList())
|
val clientCertificateChain = certificateFactory.generateCertPath(chain.toList())
|
||||||
try {
|
try {
|
||||||
@@ -146,10 +147,26 @@ object RBCS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun checkClientTrusted(chain: Array<out X509Certificate>, authType: String, socket: java.net.Socket) {
|
||||||
|
checkClientTrusted(chain, authType)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun checkClientTrusted(chain: Array<out X509Certificate>, authType: String, engine: javax.net.ssl.SSLEngine) {
|
||||||
|
checkClientTrusted(chain, authType)
|
||||||
|
}
|
||||||
|
|
||||||
override fun checkServerTrusted(chain: Array<out X509Certificate>, authType: String) {
|
override fun checkServerTrusted(chain: Array<out X509Certificate>, authType: String) {
|
||||||
throw NotImplementedError()
|
throw NotImplementedError()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun checkServerTrusted(chain: Array<out X509Certificate>, authType: String, socket: java.net.Socket) {
|
||||||
|
checkServerTrusted(chain, authType)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun checkServerTrusted(chain: Array<out X509Certificate>, authType: String, engine: javax.net.ssl.SSLEngine) {
|
||||||
|
checkServerTrusted(chain, authType)
|
||||||
|
}
|
||||||
|
|
||||||
private val acceptedIssuers = trustStore.aliases().asSequence()
|
private val acceptedIssuers = trustStore.aliases().asSequence()
|
||||||
.filter(trustStore::isCertificateEntry)
|
.filter(trustStore::isCertificateEntry)
|
||||||
.map(trustStore::getCertificate)
|
.map(trustStore::getCertificate)
|
||||||
@@ -161,8 +178,8 @@ object RBCS {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
||||||
trustManagerFactory.trustManagers.asSequence().filter { it is X509TrustManager }
|
trustManagerFactory.trustManagers.asSequence().filter { it is X509ExtendedTrustManager }
|
||||||
.single() as X509TrustManager
|
.single() as X509ExtendedTrustManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
// mavenLocal {
|
|
||||||
// content {
|
|
||||||
// includeGroup 'net.woggioni.gradle'
|
|
||||||
// includeGroup 'net.woggioni.gradle.lombok'
|
|
||||||
// includeGroup 'net.woggioni.gradle.finalguard'
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
maven {
|
maven {
|
||||||
url = getProperty('gitea.maven.url')
|
url = getProperty('gitea.maven.url')
|
||||||
}
|
}
|
||||||
@@ -26,8 +19,6 @@ dependencyResolutionManagement {
|
|||||||
versionCatalogs {
|
versionCatalogs {
|
||||||
catalog {
|
catalog {
|
||||||
from group: 'com.lys', name: 'lys-catalog', version: getProperty('lys.version')
|
from group: 'com.lys', name: 'lys-catalog', version: getProperty('lys.version')
|
||||||
// version('my-gradle-plugins', '2026.06.09')
|
|
||||||
version('netty', '4.2.14.Final')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user