Skip to content

Commit

Permalink
2.2.5 trust all https certs
Browse files Browse the repository at this point in the history
  • Loading branch information
Krosxx committed Nov 9, 2020
1 parent 1fff9a3 commit 667a155
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![](http://182.61.3.65:8082/jetbrain/plugins/dc/13075?style=badge/Jetbrains_Plugin-{dc}+-yellow.svg?style=social)](https://plugins.jetbrains.com/plugin/13075-retrofit-rest-client-2-0/)
[![](http://b.vove7.cn:8082/jetbrain/plugins/dc/13075?style=badge/Jetbrains_Plugin-{dc}+-yellow.svg?style=social)](https://plugins.jetbrains.com/plugin/13075-retrofit-rest-client-2-0/)

# Retrofit Rest Client

Expand Down
2 changes: 1 addition & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>cn.vove7.ide.plugin.rest</id>
<name>Retrofit Rest Client 2.0</name>
<version>2.2.4</version>
<version>2.2.5</version>
<vendor email="vove7@qq.com" url="https://github.com/Vove7/retrofit-rest-client">Vove7</vendor>

<description><![CDATA[
Expand Down
Binary file modified retrofit-rest-client.zip
Binary file not shown.
32 changes: 32 additions & 0 deletions src/cn/vove7/plugin/rest/https/TrustAllCerts.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cn.vove7.plugin.rest.https

import java.security.SecureRandom
import java.security.cert.X509Certificate
import javax.net.ssl.SSLContext
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager

class TrustAllCerts : X509TrustManager {
override fun checkClientTrusted(p0: Array<out X509Certificate>?, p1: String?) {
}

override fun checkServerTrusted(p0: Array<out X509Certificate>?, p1: String?) {
}

override fun getAcceptedIssuers(): Array<X509Certificate> {
return emptyArray()
}

companion object {
fun createSSLSocketFactory(): SSLSocketFactory? {
try {
val sc: SSLContext = SSLContext.getInstance("TLS")
sc.init(null, arrayOf(TrustAllCerts()), SecureRandom())
return sc.socketFactory
} catch (e: Exception) {
}
return null
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ abstract class RetrofitLineMarkerProvider : LineMarkerProvider {
return nameIdentifier ?: this
}

override fun collectSlowLineMarkers(elements: MutableList<PsiElement>, result: MutableCollection<LineMarkerInfo<PsiElement>>) {
}

private fun PsiElement.markElementToMethod(): PsiMethod {
return context as PsiMethod
}
Expand Down
10 changes: 9 additions & 1 deletion src/cn/vove7/plugin/rest/tool/RequestExecutor.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.vove7.plugin.rest.tool

import cn.vove7.plugin.rest.https.TrustAllCerts
import cn.vove7.plugin.rest.model.RequestModel
import cn.vove7.plugin.rest.model.ResponseModel
import com.intellij.openapi.util.Key
Expand Down Expand Up @@ -35,7 +36,14 @@ class RequestExecutor {
}

private fun createHttpClient(): OkHttpClient {
return OkHttpClient.Builder().build()
return OkHttpClient.Builder()
.also {
TrustAllCerts.createSSLSocketFactory()?.also { fac ->
it.sslSocketFactory(fac, TrustAllCerts())
}
}
.hostnameVerifier { _, _ -> true }
.build()
}

@Throws(IOException::class)
Expand Down

0 comments on commit 667a155

Please sign in to comment.