Secured routes

Secure routes provide the ability to use several types of TLS termination to serve certificates to the client. The following sections describe how to create re-encrypt, edge, and passthrough routes with custom certificates.

If you create routes in Microsoft Azure through public endpoints, the resource names are subject to restriction. You cannot create resources that use certain terms. For a list of terms that Azure restricts, see Resolve reserved resource name errors in the Azure documentation.

Creating a re-encrypt route with a custom certificate

You can configure a secure route using reencrypt TLS termination with a custom certificate by using the oc create route command.

Prerequisites

  • You must have a certificate/key pair in PEM-encoded files, where the certificate is valid for the route host.

  • You may have a separate CA certificate in a PEM-encoded file that completes the certificate chain.

  • You must have a separate destination CA certificate in a PEM-encoded file.

  • You must have a service that you want to expose.

Password protected key files are not supported. To remove a passphrase from a key file, use the following command:

  1. $ openssl rsa -in password_protected_tls.key -out tls.key

Procedure

This procedure creates a Route resource with a custom certificate and reencrypt TLS termination. The following assumes that the certificate/key pair are in the tls.crt and tls.key files in the current working directory. You must also specify a destination CA certificate to enable the Ingress Controller to trust the service’s certificate. You may also specify a CA certificate if needed to complete the certificate chain. Substitute the actual path names for tls.crt, tls.key, cacert.crt, and (optionally) ca.crt. Substitute the name of the Service resource that you want to expose for frontend. Substitute the appropriate hostname for www.example.com.

  • Create a secure Route resource using reencrypt TLS termination and a custom certificate:

    1. $ oc create route reencrypt --service=frontend --cert=tls.crt --key=tls.key --dest-ca-cert=destca.crt --ca-cert=ca.crt --hostname=www.example.com

    If you examine the resulting Route resource, it should look similar to the following:

    YAML Definition of the Secure Route

    1. apiVersion: route.openshift.io/v1
    2. kind: Route
    3. metadata:
    4. name: frontend
    5. spec:
    6. host: www.example.com
    7. to:
    8. kind: Service
    9. name: frontend
    10. tls:
    11. termination: reencrypt
    12. key: |-
    13. -----BEGIN PRIVATE KEY-----
    14. [...]
    15. -----END PRIVATE KEY-----
    16. certificate: |-
    17. -----BEGIN CERTIFICATE-----
    18. [...]
    19. -----END CERTIFICATE-----
    20. caCertificate: |-
    21. -----BEGIN CERTIFICATE-----
    22. [...]
    23. -----END CERTIFICATE-----
    24. destinationCACertificate: |-
    25. -----BEGIN CERTIFICATE-----
    26. [...]
    27. -----END CERTIFICATE-----

    See oc create route reencrypt --help for more options.

Creating an edge route with a custom certificate

You can configure a secure route using edge TLS termination with a custom certificate by using the oc create route command. With an edge route, the Ingress Controller terminates TLS encryption before forwarding traffic to the destination pod. The route specifies the TLS certificate and key that the Ingress Controller uses for the route.

Prerequisites

  • You must have a certificate/key pair in PEM-encoded files, where the certificate is valid for the route host.

  • You may have a separate CA certificate in a PEM-encoded file that completes the certificate chain.

  • You must have a service that you want to expose.

Password protected key files are not supported. To remove a passphrase from a key file, use the following command:

  1. $ openssl rsa -in password_protected_tls.key -out tls.key

Procedure

This procedure creates a Route resource with a custom certificate and edge TLS termination. The following assumes that the certificate/key pair are in the tls.crt and tls.key files in the current working directory. You may also specify a CA certificate if needed to complete the certificate chain. Substitute the actual path names for tls.crt, tls.key, and (optionally) ca.crt. Substitute the name of the service that you want to expose for frontend. Substitute the appropriate hostname for www.example.com.

  • Create a secure Route resource using edge TLS termination and a custom certificate.

    1. $ oc create route edge --service=frontend --cert=tls.crt --key=tls.key --ca-cert=ca.crt --hostname=www.example.com

    If you examine the resulting Route resource, it should look similar to the following:

    YAML Definition of the Secure Route

    1. apiVersion: route.openshift.io/v1
    2. kind: Route
    3. metadata:
    4. name: frontend
    5. spec:
    6. host: www.example.com
    7. to:
    8. kind: Service
    9. name: frontend
    10. tls:
    11. termination: edge
    12. key: |-
    13. -----BEGIN PRIVATE KEY-----
    14. [...]
    15. -----END PRIVATE KEY-----
    16. certificate: |-
    17. -----BEGIN CERTIFICATE-----
    18. [...]
    19. -----END CERTIFICATE-----
    20. caCertificate: |-
    21. -----BEGIN CERTIFICATE-----
    22. [...]
    23. -----END CERTIFICATE-----

    See oc create route edge --help for more options.

Creating a passthrough route

You can configure a secure route using passthrough termination by using the oc create route command. With passthrough termination, encrypted traffic is sent straight to the destination without the router providing TLS termination. Therefore no key or certificate is required on the route.

Prerequisites

  • You must have a service that you want to expose.

Procedure

  • Create a Route resource:

    1. $ oc create route passthrough route-passthrough-secured --service=frontend --port=8080

    If you examine the resulting Route resource, it should look similar to the following:

    A Secured Route Using Passthrough Termination

    1. apiVersion: route.openshift.io/v1
    2. kind: Route
    3. metadata:
    4. name: route-passthrough-secured (1)
    5. spec:
    6. host: www.example.com
    7. port:
    8. targetPort: 8080
    9. tls:
    10. termination: passthrough (2)
    11. insecureEdgeTerminationPolicy: None (3)
    12. to:
    13. kind: Service
    14. name: frontend
    1The name of the object, which is limited to 63 characters.
    2The termination field is set to passthrough. This is the only required tls field.
    3Optional insecureEdgeTerminationPolicy. The only valid values are None, Redirect, or empty for disabled.

    The destination pod is responsible for serving certificates for the traffic at the endpoint. This is currently the only method that can support requiring client certificates, also known as two-way authentication.