diff --git a/SECURITY.md b/SECURITY.md
index 54e610a887..ab617488f7 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -1,10 +1,16 @@
# Security Policy
-For information on gRPC Security Policy and reporting potentional security issues, please see [gRPC CVE Process](https://github.com/grpc/proposal/blob/master/P4-grpc-cve-process.md).
+For information on gRPC Security Policy and reporting potentional security
+issues, please see [gRPC CVE Process][].
+
+[gRPC CVE Process]: https://github.com/grpc/proposal/blob/master/P4-grpc-cve-process.md
# Authentication
-gRPC supports a number of different mechanisms for asserting identity between an client and server. This document provides code samples demonstrating how to provide SSL/TLS encryption support and identity assertions in Java, as well as passing OAuth2 tokens to services that support it.
+gRPC supports a number of different mechanisms for asserting identity between an
+client and server. This document provides code samples demonstrating how to
+provide SSL/TLS encryption support and identity assertions in Java, as well as
+passing OAuth2 tokens to services that support it.
# Transport Security (TLS)
@@ -19,25 +25,28 @@ BoringSSL](#tls-with-netty-tcnative-on-boringssl).
## TLS on Android
On Android we recommend the use of the [Play Services Dynamic Security
-Provider](https://www.appfoundry.be/blog/2014/11/18/Google-Play-Services-Dynamic-Security-Provider/)
-to ensure your application has an up-to-date OpenSSL library with the necessary
-cipher-suites and a reliable ALPN implementation. This requires [updating the
-security provider at
-runtime](https://developer.android.com/training/articles/security-gms-provider.html).
+Provider][] to ensure your application has an up-to-date OpenSSL library with
+the necessary cipher-suites and a reliable ALPN implementation. This requires
+[updating the security provider at runtime][config-psdsp].
Although ALPN mostly works on newer Android releases (especially since 5.0),
there are bugs and discovered security vulnerabilities that are only fixed by
upgrading the security provider. Thus, we recommend using the Play Service
Dynamic Security Provider for all Android versions.
-*Note: The Dynamic Security Provider must be installed **before** creating a gRPC OkHttp channel. gRPC's OkHttpProtocolNegotiator statically initializes the security protocol(s) available to gRPC, which means that changes to the security provider after the first channel is created will not be picked up by gRPC.*
+*Note: The Dynamic Security Provider must be installed **before** creating a
+gRPC OkHttp channel. gRPC statically initializes the security protocol(s)
+available, which means that changes to the security provider after the first
+channel is created will not be noticed by gRPC.*
+
+[Play Services Dynamic Security Provider]: https://www.appfoundry.be/blog/2014/11/18/Google-Play-Services-Dynamic-Security-Provider/
+[config-psdsp]: https://developer.android.com/training/articles/security-gms-provider.html
### Bundling Conscrypt
If depending on Play Services is not an option for your app, then you may bundle
[Conscrypt](https://conscrypt.org) with your application. Binaries are available
-on [Maven
-Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.conscrypt%20a%3Aconscrypt-android).
+on [Maven Central][conscrypt-maven].
Like the Play Services Dynamic Security Provider, you must still "install"
Conscrypt before use.
@@ -50,10 +59,12 @@ import java.security.Security;
Security.insertProviderAt(Conscrypt.newProvider(), 1);
```
+[conscrypt-maven]: https://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.conscrypt%20a%3Aconscrypt-android
+
## TLS on non-Android
-JDK versions prior to Java 9 do not support ALPN and are either missing AES GCM
-support or have 2% the performance of OpenSSL.
+OpenJDK versions prior to Java 8u252 do not support ALPN. Java 8 has 10% the
+performance of OpenSSL.
We recommend most users use grpc-netty-shaded, which includes netty-tcnative on
BoringSSL. It includes pre-built libraries for 64 bit Windows, OS X, and 64 bit
@@ -243,37 +254,6 @@ import java.security.Security;
Security.insertProviderAt(Conscrypt.newProvider(), 1);
```
-### TLS with Jetty ALPN
-
-**Please do not use Jetty ALPN**
-
-gRPC historically supported Jetty ALPN for ALPN on Java 8. While functional, it
-suffers from poor performance and breakages when the JRE is upgraded.
-When mis-matched to the JRE version, it can also produce unpredictable errors
-that are hard to diagnose. When using it, it became common practice that any
-time we saw a TLS failure that made no sense we would blame a Jetty ALPN/JRE
-version mismatch and we were overwhelmingly correct. The Jetty ALPN agent makes
-it much easier to use, but we still strongly discourage Jetty ALPN's use.
-
-When using Jetty ALPN with Java 8, realize that performance will be 2-10% that
-of the other options due to a slow AES GCM implementation in Java.
-
-#### Configuring Jetty ALPN in Web Containers
-
-Some web containers, such as [Jetty](https://www.eclipse.org/jetty/documentation/current/jetty-classloading.html) restrict access to server classes for web applications. A gRPC client running within such a container must be properly configured to allow access to the ALPN classes. In Jetty, this is done by including a `WEB-INF/jetty-env.xml` file containing the following:
-
-```xml
-
-
-
-
-
-
-
- -org.eclipse.jetty.alpn.
-
-
-```
## Enabling TLS on a server
To use TLS on the server, a certificate chain and private key need to be
@@ -281,35 +261,36 @@ specified in PEM format. The standard TLS port is 443, but we use 8443 below to
avoid needing extra permissions from the OS.
```java
-Server server = ServerBuilder.forPort(8443)
- // Enable TLS
- .useTransportSecurity(certChainFile, privateKeyFile)
+ServerCredentials creds = TlsServerCredentials.create(certChainFile, privateKeyFile);
+Server server = Grpc.newServerBuilderForPort(8443, creds)
.addService(serviceImplementation)
- .build();
-server.start();
+ .build()
+ .start();
```
If the issuing certificate authority is not known to the client then a properly
-configured SslContext or SSLSocketFactory should be provided to the
-NettyChannelBuilder or OkHttpChannelBuilder, respectively.
+configured trust manager should be provided to TlsChannelCredentials and used to
+construct the channel.
## Mutual TLS
[Mutual authentication][] (or "client-side authentication") configuration is similar to the server by providing truststores, a client certificate and private key to the client channel. The server must also be configured to request a certificate from clients, as well as truststores for which client certificates it should allow.
```java
-Server server = NettyServerBuilder.forPort(8443)
- .sslContext(GrpcSslContexts.forServer(certChainFile, privateKeyFile)
- .trustManager(clientCAsFile)
- .clientAuth(ClientAuth.REQUIRE)
- .build());
+ServerCredentials creds = TlsServerCredentials.newBuilder()
+ .keyManager(certChainFile, privateKeyFile)
+ .trustManager(clientCAsFile)
+ .clientAuth(TlsServerCredentials.ClientAuth.REQUIRE)
+ .build();
```
-Negotiated client certificates are available in the SSLSession, which is found in the `TRANSPORT_ATTR_SSL_SESSION` attribute of Grpc. A server interceptor can provide details in the current Context.
+Negotiated client certificates are available in the SSLSession, which is found
+in the `Grpc.TRANSPORT_ATTR_SSL_SESSION` attribute of the call. A server
+interceptor can provide details in the current Context.
```java
-// The application uses this in its handlers
-public final static Context.Key SSL_SESSION_CONTEXT = Context.key("SSLSession");
+// The application uses this in its handlers.
+public static final Context.Key SECURITY_INFO = Context.key("my.security.Info");
@Override
public ServerCall.Listener interceptCall(ServerCall call,
@@ -318,8 +299,12 @@ public ServerCall.Listener interceptCall(ServerCall