-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove netty-specific credentials factory in client
See also #10
- Loading branch information
Showing
5 changed files
with
126 additions
and
131 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
...rpc-core/src/main/java/org/springframework/grpc/internal/InsecureTrustManagerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 2024-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.grpc.internal; | ||
|
||
import java.net.Socket; | ||
import java.security.InvalidAlgorithmParameterException; | ||
import java.security.KeyStore; | ||
import java.security.KeyStoreException; | ||
import java.security.Provider; | ||
import java.security.cert.CertificateException; | ||
import java.security.cert.X509Certificate; | ||
|
||
import javax.net.ssl.ManagerFactoryParameters; | ||
import javax.net.ssl.SSLEngine; | ||
import javax.net.ssl.TrustManager; | ||
import javax.net.ssl.TrustManagerFactory; | ||
import javax.net.ssl.TrustManagerFactorySpi; | ||
import javax.net.ssl.X509ExtendedTrustManager; | ||
import javax.net.ssl.X509TrustManager; | ||
|
||
/** | ||
* A custom implementation of the TrustManagerFactory class that provides an insecure | ||
* trust manager. This trust manager does not perform any certificate validation and | ||
* accepts all certificates. It is intended for testing or development purposes only and | ||
* should not be used in production environments. | ||
*/ | ||
public class InsecureTrustManagerFactory extends TrustManagerFactory { | ||
|
||
public static final TrustManagerFactory INSTANCE = new InsecureTrustManagerFactory(); | ||
|
||
private static final Provider provider = new Provider("", "0.0", "") { | ||
private static final long serialVersionUID = -2680540247105807895L; | ||
|
||
}; | ||
|
||
protected InsecureTrustManagerFactory() { | ||
super(new SimpleTrustManagerFactorySpi(), provider, ""); | ||
} | ||
|
||
private final static class InsecureTrustManager extends X509ExtendedTrustManager { | ||
|
||
static final InsecureTrustManager INSTANCE = new InsecureTrustManager(); | ||
|
||
static final X509Certificate[] EMPTY_CERTS = new X509Certificate[] {}; | ||
|
||
@Override | ||
public void checkClientTrusted(X509Certificate[] chain, String authType) { | ||
} | ||
|
||
@Override | ||
public void checkServerTrusted(X509Certificate[] chain, String authType) { | ||
} | ||
|
||
@Override | ||
public X509Certificate[] getAcceptedIssuers() { | ||
return EMPTY_CERTS; | ||
} | ||
|
||
@Override | ||
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) | ||
throws CertificateException { | ||
} | ||
|
||
@Override | ||
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) | ||
throws CertificateException { | ||
} | ||
|
||
@Override | ||
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) | ||
throws CertificateException { | ||
} | ||
|
||
@Override | ||
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) | ||
throws CertificateException { | ||
} | ||
|
||
} | ||
|
||
private final static class SimpleTrustManagerFactorySpi extends TrustManagerFactorySpi { | ||
|
||
static final TrustManager[] TRUST_ALL = new X509TrustManager[] { InsecureTrustManager.INSTANCE }; | ||
|
||
@Override | ||
protected void engineInit(KeyStore keyStore) throws KeyStoreException { | ||
} | ||
|
||
@Override | ||
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) | ||
throws InvalidAlgorithmParameterException { | ||
} | ||
|
||
@Override | ||
protected TrustManager[] engineGetTrustManagers() { | ||
return TRUST_ALL; | ||
} | ||
|
||
} | ||
|
||
} |
55 changes: 0 additions & 55 deletions
55
.../java/org/springframework/grpc/autoconfigure/client/GrpcChannelFactoryConfigurations.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
.../org/springframework/grpc/autoconfigure/client/ShadedNettyChannelCredentialsProvider.java
This file was deleted.
Oops, something went wrong.