You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

Introduction

  • The connections from Controllers to Agents can be secured by HTTPS with TLS/SSL certificates.
  • This article describes the steps required to set up secure HTTPS communication from a Controller to an Agent. This includes using a standalone Controller or a Controller cluster with a primary and standby instance.

Prerequisites

  • Certificate stores can be managed from the command line and using tools that provide a GUI for this purpose:
    • the Java keytool is available from the Java JRE or JDK,
    • the Keystore Explorer, which is an open source utility to graphically manage certificate stores.
  • Starting from Java 9 the PKCS12 keystore type is default and is not required to be specified with keytool.
  • The following sections assume a PKCS12 keystore/truststore format. For Unix OS the .p12 file extension frequently is used, for Windows OS the .pfx extension is preferably used. Both file extensions indicate the same PKCS12 format and can be used interchangeably.

Certificate Management

Private keys and certificates should be distributed as follows:



Explanation:

  • The keystore and truststore shown in orange are required for any connections of a Controller to an Agent.
    • The Agent's private key and certificate for Server Authentication are added to the Agent's keystore. If the certificate is self-signed then it has to be added to the Controller's truststore as well.
    • This step can be skipped if a CA-signed certificate is used as the Root Certificate in the Controller's truststore is sufficient to verify Agent certificates.
  • The keystore and truststore shown in green are required if mutual authentication is in place for certificate based Client Authentication (default).

Secure Connection Setup

In the following the JS7_CONTROLLER_CONFIG_DIR placeholder specifies the configuration directory of the Controller. The JS7_AGENT_HOME, JS7_AGENT_CONFIG_DIR placeholders specify the directories where the Agent is installed and configured.

Secure Connections from Controller to Agent

This configuration is applied in order to secure the connection if the Controller and Agent are not operated on the same server and network interface.

Secure connections require authentication.

For a complete list of related configuration items see JS7 - Agent Configuration Items.

The following chapters assume mutual authentication to be in place.

Step 1: Create the Agent Keystore

  • On the Agent server create the keystore using the keytool from your Java JRE or JDK. Alternatively import a private key and certificate that you received from your certificate authority:
    • For use with a third party utility create a keystore, e.g. https-keystore.p12, in PKCS12 format and import:
      • the Agent private key and certificate for Server Authentication
      • the Root CA certificate
      • Intermediate CA certificate(s)
    • For use with keytool create the keystore with the private key and certificate for Server Authentication from the command line. The examples below show one possible approach for certificate management. However, there are other ways to achieve similar results.
      • Example for creating a private key and CA-signed certificate with a PKCS12 keystore:

        Example how to create and add a private key and CA-signed certificate to a PKCS12 keystore
        # should your Agent's private key and certificate be provided with a .jks keystore (keypair.jks) then temporarily convert the keystore to pkcs12 (keystore.p12)
        #   for later use with openssl, assuming the alias name of the Agent private key is "agent.example.com"
        # keytool -importkeystore -srckeystore keypair.jks -srcstoretype JKS -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias agent.example.com
        
        # assuming your Agent's private key is from a pkcs12 keystore (keystore.p12), store the Agent's private key in a .key file in PEM format (agent-https.key)
        openssl pkcs12 -in keystore.p12 -nocerts -out agent-https.key
        
        # concatenate the CA root certificate and the CA intermediate certificate to a single CA Bundle certificate file (ca-bundle.crt)
        cat RootCACertificate.crt > ca-bundle.crt
        cat CACertificate.crt >> ca-bundle.crt
        
        # Export the Agent's private key (agent-https.key), Agent's certificate (agent-https.crt) and CA Bundle (ca-bundle.crt) in PEM format to a new keystore (https-keystore.p12)
        #   assume the fully qualified domain name (FQDN) of the Agent server is agent.example.com
        openssl pkcs12 -export -in agent-https.crt -inkey agent-https.key -chain -CAfile ca-bundle.crt -name agent.example.com -out JS7_AGENT_CONFIG_DIR/private/https-keystore.p12
        
        # should you require use of a .jks keystore type then convert the pkcs12 keystore assuming the alias name of the Agent's private key is "agent.example.com"
        # keytool -importkeystore -srckeystore agent-https.p12 -srcstoretype PKCS12 -destkeystore JS7_AGENT_CONFIG_DIR/private/https-keystore.jks -deststoretype JKS -srcalias agent.example.com
      • Example for creating a private key and self-signed certificate with a PKCS12 keystore:

        Example how to generate a private key and self-signed certificate for import into a PKCS12 keystore
        # generate the Agent's private key with alias name "agent.example.com" and certificate in a keystore (https-keystore.p12)
        #   use the fully qualified domain name (FQDN) assumed to be agent.example.com and name of your organization for the distinguished name
        keytool -genkey -alias "agent.example.com" -dname "CN=agent.example.com,O=organization" -validity 1461 -keyalg RSA -keysize 2048 -keypass jobscheduler -keystore "JS7_AGENT_CONFIG_DIR/private/https-keystore.p12" -storepass jobscheduler -storetype PKCS12
        
      • Example for creating a private key and self-signed certificate with JKS keystore:

        Example how to generate a private key and self-signed certificate for import into a JKS keystore
        # generate Agent's private key with alias name "agent.example.com" and certificate in a keystore (https-keystore.jks)
        #   use the fully qualified domain name (FQDN) assumed to be agent.example.com and name of your organization for the distinguished name
        keytool -genkey -alias "agent.example.com" -dname "CN=agent.example.com,O=organization" -validity 1461 -keyalg RSA -keysize 2048 -keypass jobscheduler -keystore "JS7_AGENT_CONFIG_DIR/private/https-keystore.jks" -storepass jobscheduler -storetype JKS
      • Explanation:

        • The -dname option specifies the certificate issuer, therefore use your own set of CN, O, OU, DC that specify the issuer's Distinguished Name. The O setting is required for the issuer.
        • The -keypass option accepts the password that you will need later on to manage your private key.
        • The -keystore option specifies the location of the keystore file. The keystore file should be in reach of the Agent, it is recommended that you use the sub-folder private in the JS7_AGENT_CONFIG_DIR directory.
        • The -storepass option specifies the password for access to the keystore file.
        • The -storetype option is used to specify the PKCS12 or JKS keystore format.
    • With the keystore set up specify the relevant properties with the JS7_AGENT_CONFIG_DIR/private/private.conf configuration file:
      • Example

        Example for private.conf file specifying the Agent keystore
        js7 {
            web {
                # keystore and truststore locations for https connections
                https {
                    keystore {
                        # Default: ${js7.config-directory}"/private/https-keystore.p12"
                        file=${js7.config-directory}"/private/https-keystore.p12"
                        key-password="jobscheduler"
                        store-password="jobscheduler"
                    }
                }
            }
        }


        Explanation:
        • js7.web.https.keystore.file is used for the path to the keystore.
        • js7.web.https.keystore.key-password is used for access to the private key.
        • js7.web.https.keystore.store-password is used for access to the keystore

Step 2: Set up Authentication for Agent

  • By default mutual authentication is in place.
    • The Controller is challenged by the Agent to present its Client Authentication certificate which is then verified by the Agent.
    • If a Controller Cluster is used then connections from both Controller instances are authenticated by the Distinguished Name of the Controller instance's Client Authentication certificate.
  • The JS7_AGENT_CONFIG_DIR/private/private.conf configuration file should include authentication details like this:

    Example for private.conf file specifying Controller authentication
    js7 {
        auth {
            users {
                # Controller ID for connections by primary/standby Controller instance
                jobscheduler {
                    distinguished-names=[
                        "DNQ=SOS CA, CN=primary_controller_client, OU=IT, O=SOS, L=Berlin, ST=Berlin, C=DE",
                        "DNQ=SOS CA, CN=secondary_controller_client, OU=IT, O=SOS, L=Berlin, ST=Berlin, C=DE"
                    ]
                }
            }
        }
    }


    Explanation:
    • The jobscheduler user account is an example of a Controller ID that is specified during Controller installation.
    • The distinguished-names property allows the addition of a number of Distinguished Names as available from the subject of Client Authentication certificates that are used by Controller instances when connecting to the Agent.
      • Except for whitespace between attributes the precise sequence and values as available from the certificate's subject has to match this property value.

Step 3: Set up the Agent Instance Start Script for HTTPS

  • To make an Agent use HTTPS, the relevant port setting has to be specified with the Agent's Instance Start Script.

    • For Unix the Instance Start Script is available from JS7_AGENT_HOME/bin/agent_<port>.sh:

      Example for HTTP and HTTPS port settings with Agent Instance Start Script for Unix
      # Sets the http port for the JS7 Agent.
      # Without this setting the default port 4445 is used.
      # If just a port is specified then the JS7 Agent listens to all
      # available network interfaces. This corresponds to 0.0.0.0:<port>.
      # Use the form <ip address or hostname>:<port> to indicate
      # a specific network interface the JS7 Agent should listen to.
      # The command line option --http-port beats the environment
      # variable JS7_AGENT_HTTP_PORT.
      
      JS7_AGENT_HTTP_PORT=localhost:4445
      
      
      # In addition to the http port an https port for the
      # JS7 Agent can be specified. If just a port is specified
      # then the JS7 Agent listens to all available network interfaces.
      # This corresponds to using 0.0.0.0:<port>.
      # Use the form <ip address or hostname>:<port> to indicate
      # a specific network interface the JS7 Agent should listen to.
      # The command line option --https-port beats the environment
      # variable JS7_AGENT_HTTPS_PORT.
      
      JS7_AGENT_HTTPS_PORT=agent.example.com:4445
    • For Windows the Instance Start Script is available from JS7_AGENT_HOME\bin\agent_<port>.cmd:

      Example for HTTP and HTTPS port settings with Agent Instance Start Script for Windows
      rem # Sets the http port for the JS7 Agent.
      rem # Without this setting the default port 4445 is used.
      rem # If just a port is specified then the JS7 Agent listens to all
      rem # available network interfaces. This corresponds to 0.0.0.0:<port>.
      rem # Use the form <ip address or hostname>:<port> to indicate
      rem # a specific network interface the JS7 Agent should listen to.
      rem # The command line option --http-port beats the environment
      rem # variable JS7_AGENT_HTTP_PORT.
      
      set JS7_AGENT_HTTP_PORT=localhost:4445
      
      
      rem # In addition to the http port an https port for the
      rem # JS7 Agent can be specified. If just a port is specified
      rem # then the JS7 Agent listens to all available network interfaces.
      rem # This corresponds to using 0.0.0.0:<port>.
      rem # Use the form <ip address or hostname>:<port> to indicate
      rem # a specific network interface the JS7 Agent should listen to.
      rem # The command line option --https-port beats the environment
      rem # variable JS7_AGENT_HTTPS_PORT.
      
      set JS7_AGENT_HTTPS_PORT=agent.example.com:4445


      Explanation:
      • The HTTP port is required but is limited to the localhost network interface with the localhost prefix.
      • The HTTPS port is specified with the hostname prefix that indicates the network interface.

Step 4: Configure the Controller Truststore

The Controller truststore is added the Root CA certificate. If self-signed certificates are used then each certificate is added to the Controller's truststore.

  • On the Controller server create the truststore using the keytool from your Java JRE or JDK or a third party utility.
    • For use with a third party utility create a truststore, e.g. https-truststore.p12, in PKCS12 format and import:
      • the Root CA certificate
    • For use with keytool create the truststore in PKCS12 or JKS format with the Root CA certificate. The examples below show one possible approach for certificate management. However, there are other ways to achieve similar results.
      • Example for importing a Root CA certificate to a PKCS12 truststore:

        Example how to import a CA-signed certificate into a PKCS12 Truststore
        # import Root CA certificate in PEM format to a PKCS12 truststore (https-truststore.p12)
        keytool -importcert -alias "root-ca" -file "RootCACertificate.crt" -keystore "JS7_CONTROLLER_CONFIG_DIR/private/https-truststore.p12" -storetype PKCS12
      • Example for use of a self-signed Agent certificate with a PKCS12 truststore:

        Example for import of a self-signed Agent certificate to Controller PKCS12 Truststore
        # on Agent server: export Agent's certificate from keystore (https-keystore.p12) identified by its alias name (agent.example.com) to a file in PEM format (agent-https.crt)
        keytool -exportcert -rfc -noprompt -file "agent-https.crt" -alias "agent.example.com" -keystore "JS7_AGENT_CONFIG_DIR/private/https-keystore.p12" -storepass jobscheduler -storetype PKCS12
        
        # on Controller server: import the Agent's certificate from a file in PEM format (agent-https.crt) identified by its alias name (agent.example.com) to the Controller's PKCS12 truststore (https-truststore.p12)
        keytool -importcert -noprompt -file "agent-https.crt" -alias "agent.example.com" -keystore "JS7_CONTROLLER_CONFIG_DIR/private/https-truststore.p12" -storepass jobscheduler -storetype PKCS12 -trustcacerts 
      • Example for use of a self-signed Agent certificate with a JKS truststore:

        Example for import of a self-signed Agent certificate to Controller JKS Truststore
        # on Agent server: export Agent's certificate from keystore (https-keystore.jks) identified by its alias name (agent.example.com) to a file in PEM format (agent-https.crt)
        keytool -exportcert -rfc -noprompt -file "agent-https.crt" -alias "agent.example.com" -keystore "JS7_AGENT_CONFIG_DIR/private/https-keystore.jks" -storepass jobscheduler -storetype JKS
        
        # import the Agent's certificate from a file in PEM format (agent-https.crt) identified by its alias name (agent.example.com) to the Controller's JKS truststore (https-truststore.jks)
        keytool -importcert -noprompt -file "agent-https.crt" -alias "agent.example.com" -keystore "JS7_CONTROLLER_CONFIG_DIR/private/https-truststore.jks" -storepass jobscheduler -storetype JKS -trustcacerts
  • On the Controller server specify the location of the truststore with the JS7_CONTROLLER_CONFIG_DIR/private/private.conf configuration file:
    • Example

      Example for private.conf file specifying the Controller truststore
      js7 {
          web {
              # keystore and truststore locations for https connections
              https {
                  truststores=[
                      {
                          # Default: ${js7.config-directory}"/private/https-truststore.p12"
                          file=${js7.config-directory}"/private/https-truststore.p12"
                          store-password=jobscheduler
                      }
                  ]
              }
          }
      }


      Explanation:
      • js7.web.https.truststores.file is used for the path to the truststore.
      • js7.web.https.truststores.store-password is used for access to the truststore.

Mutual Authentication for Controller and Agent

This configuration is applied in order to enable mutual authentication:

  • from the Controller to the Agent:
    • the Controller verifies the Agent's certificate for Server Authentication
    • the Agent verifies the Controller's certificate for Client Authentication
  • from pairing Controller instances.

If mutual authentication cannot be used then consider explanations from the JS7 - Configuration for HTTPS Server Authentication with Passwords article.

Step 1: Create/Update Controller Client Keystore

For mutual authentication the Controller has to hold a Client Authentication private key and certificate in its keystore.

  • This can be simplified by using a private key/certificate pair that is created for both extended key uses Server Authentication and Client Authentication. In this case a single private key and certificate is stored with the Controller's keystore as indicated in the JS7 - Controller HTTPS Connections article.
  • If separate private key/certificate pairs are to be used for Server Authentication and Client Authentication then the use of separate certificate stores for the Controller is recommended:
    • The keystore holds the private key/certificate for Server Authentication.
    • The client keystore holds the private key/certificate for Client Authentication.

The following steps are applied if a separate client keystore is used with a Controller.

  • On the Controller server create the client keystore using the keytool from your Java JRE or JDK or a third party utility.
    • For use with a third party utility create a client keystore, e.g. https-client-keystore.p12, in PKCS12 format and import:
      • the Controller private key and certificate for Client Authentication
      • the Root CA certificate
      • Intermediate CA certificate(s)
    • For use with keytool create the client keystore in PKCS12 or JKS format according to the steps indicated in the JS7 - Controller HTTPS Connections: Step 1: Create Controller Keystore article.
      • Apply the steps described to the client keystore and use the private key/certificate pair for Client Authentication.
  • The location of the client keystore is added to the JS7_CONTROLLER_CONFIG_DIR/private/private.conf configuration file as shown:

    • Example for PKCS12 client keystore:

      Example how to specify the client keystore location with private.conf file
      js7 {
          web {
              # keystore and truststore location for https connections
              https {
                  client-keystore {
                      # Default: ${js7.config-directory}"/private/https-client-keystore.p12"
                      file=${js7.config-directory}"/private/https-client-keystore.p12"
                      key-password=jobscheduler
                      store-password=jobscheduler
                  }
              }
          }
      }

Step 2: Create Agent Truststore

  • On the Agent server create the truststore using the keytool from your Java JRE or JDK or a third party utility.
    • For use with a third party utility create a truststore, e.g. https-truststore.p12, in PKCS12 format and import:
      • the Root CA certificate
    • For use with keytool create the truststore in PKCS12 or JKS format with the Root CA certificate. The examples below show one possible approach for certificate management. However, there are other ways to achieve similar results.
      • Example for importing of a Root CA certificate to a PKCS12 truststore:

        Example how to import a CA-signed certificate into a PKCS12 truststore
        # on the Agent server: import Root CA certificate in PEM format to a PKCS12 truststore (https-truststore.p12)
        keytool -importcert -alias "root-ca" -file "RootCACertificate.crt" -keystore "JS7_AGENT_CONFIG_DIR/private/https-truststore.p12" -storetype PKCS12
      • Example for exporting/importing a self-signed Client Authentication certificate to a PKCS12 keystore:

        Example how to export/import a self-signed certificate to a PKCS12 truststore
        # on the Controller server: export the Controller's client certificate from the client keystore (https-client-keystore.p12) identified by its alias name (controller-client-https) to a file in PEM format (controller-client-https.crt)
        keytool -exportcert -rfc -noprompt -file "controller-client-https.crt" -alias "controller-client-https" -keystore "JS7_CONTROLLER_CONFIG_DIR/private/https-client-keystore.p12" -storepass jobscheduler -storetype PKCS12
        
        # on the Agent server: import the Controller's client certificate in PEM format to a PKCS12 truststore (https-truststore.p12)
        keytool -importcert -alias "controller-client-https" -file "controller-client-https.crt" -keystore "JS7_AGENT_CONFIG_DIR/private/https-truststore.p12" -storetype PKCS12
      • Example for exporting/importing a self-signed Client Authentication certificate to a JKS keystore:

        Example how to export/import a self-signed certificate to a JKS truststore
        # on Controller server: export Controller's client certificate from client keystore (https-client-keystore.jks) identified by its alias name (controller-client-https) to a file in PEM format (controller-client-https.crt)
        keytool -exportcert -rfc -noprompt -file "controller-client-https.crt" -alias "controller-client-https" -keystore "JS7_CONTROLLER_CONFIG_DIR/private/https-client-keystore.jks" -storepass jobscheduler -storetype JKS
        
        # on Agent server: import Controller's client certificate in PEM format to a JKS truststore (https-truststore.jks)
        keytool -importcert -alias "controller-client-https" -file "controller-client-https.crt" -keystore "JS7_AGENT_CONFIG_DIR/private/https-truststore.jks" -storetype JKS

Notes

  • A restart of the relevant components is required to apply modifications to the Agent's JS7_AGENT_CONFIG_DIR/private/private.conf file and the Controller's JS7_CONTROLLER_CONFIG_DIR/private/private.conf file.

Further Resources


  • No labels