Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4d4606c8
authored
Mar 17, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除冗余工具类及方法
parent
b5200563
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
53 deletions
+0
-53
app/src/main/java/com/bgycc/smartcanteen/api/SCRetrofit.java
+0
-7
app/src/main/java/com/bgycc/smartcanteen/utils/TrustAllCerts.java
+0
-46
No files found.
app/src/main/java/com/bgycc/smartcanteen/api/SCRetrofit.java
View file @
4d4606c8
package
com
.
bgycc
.
smartcanteen
.
api
;
package
com
.
bgycc
.
smartcanteen
.
api
;
import
com.bgycc.smartcanteen.BuildConfig
;
import
com.bgycc.smartcanteen.BuildConfig
;
import
com.bgycc.smartcanteen.utils.TrustAllCerts
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -35,12 +34,6 @@ public class SCRetrofit {
...
@@ -35,12 +34,6 @@ public class SCRetrofit {
return
builder
;
return
builder
;
}
}
public
static
OkHttpClient
.
Builder
createUnsafeOkHttpClientBuilder
()
{
return
createOkHttpClientBuilder
()
.
hostnameVerifier
(
new
TrustAllCerts
.
TrustAllHostnameVerifier
())
.
sslSocketFactory
(
TrustAllCerts
.
createSSLSocketFactory
(),
new
TrustAllCerts
());
}
private
static
Retrofit
createRetrofit
(
OkHttpClient
client
)
{
private
static
Retrofit
createRetrofit
(
OkHttpClient
client
)
{
return
new
Retrofit
.
Builder
()
return
new
Retrofit
.
Builder
()
.
client
(
client
)
.
client
(
client
)
...
...
app/src/main/java/com/bgycc/smartcanteen/utils/TrustAllCerts.java
deleted
100644 → 0
View file @
b5200563
package
com
.
bgycc
.
smartcanteen
.
utils
;
import
android.annotation.SuppressLint
;
import
java.security.SecureRandom
;
import
java.security.cert.X509Certificate
;
import
javax.net.ssl.HostnameVerifier
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.SSLSession
;
import
javax.net.ssl.SSLSocketFactory
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
@SuppressLint
(
"TrustAllX509TrustManager"
)
public
class
TrustAllCerts
implements
X509TrustManager
{
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
{}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
{}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
new
X509Certificate
[
0
];}
public
static
SSLSocketFactory
createSSLSocketFactory
()
{
SSLSocketFactory
ssfFactory
=
null
;
try
{
SSLContext
sc
=
SSLContext
.
getInstance
(
"SSL"
);
sc
.
init
(
null
,
new
TrustManager
[]
{
new
TrustAllCerts
()
},
new
SecureRandom
());
ssfFactory
=
sc
.
getSocketFactory
();
}
catch
(
Exception
ignored
)
{
}
return
ssfFactory
;
}
public
static
class
TrustAllHostnameVerifier
implements
HostnameVerifier
{
@SuppressLint
(
"BadHostnameVerifier"
)
@Override
public
boolean
verify
(
String
hostname
,
SSLSession
session
)
{
return
true
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment