クラスタ内のノード間の通信を保護するために、Transport Layer Security(TLS)を使用して通信を暗号化します。この基本セキュリティ設定は、承認されていないノードによるクラスタへのアクセス防止に役立ちます。

セキュリティで保護されたクラスタの Elastic Search ノードでは、他のノードとの通信を開始する前に、認証局(CA)によって署名された証明書を使用して自身を識別する必要があります。クラスタでは、これらの証明書の真正性を検証する必要があります。認証局(CA)はデジタル証明書を発行する信頼できるエンティティです。これらの証明書は、暗号化でエンティティを公開キーとリンクするために使用されるデータファイルです。

証明書はイベントサービスにバンドルされていません。独自の CA を使用して、セキュリティで保護されていない既存のクラスタでセキュリティを有効にするか、トランスポート インターフェイスで TLS を手動で設定できます。TLS を使用して HTTP トラフィックを保護することもできます。

イベントサービスバージョン 23.4.0 では、次のソフトウェアバージョンと変数がサポートされます。

認証Basic 認証
TLS バージョンTLSv1.3
APPLICATION_HOME(変数)/home/ec2-user/appdynamics/platform/product/events-service/processor

トランスポート インターフェイスで Basic 認証と TLS を有効にする

クラスタに複数のノードがある場合は、Basic 認証を有効にしてから、ノード間の Transport Layer Security(TLS)を設定する必要があります。実稼働モードのクラスタでは、Basic 認証では不十分です。

ElasticSearch ノード間通信では認証はサポートされていません。


  1. イベントサービスサーバーを停止します。
  2. 次のように、クラスタ内のすべてのノードで Basic 認証を有効にします。

    On every node

    A. export ES_JAVA_HOME=$APPLICATION_HOME/jre
    B. cd $APPLICATION_HOME/elasticsearch
    C. chmod +x bin/elasticsearch-keystore
    D. bin/elasticsearch-keystore add bootstrap.password # Enter the password for 'elastic' superuser. Save this as this will be needed for any operation on elsticsearch and will be used by events-service to authenticated the requests to elasticsearch
    E. cd $APPLICATION_HOME/conf/security # mkdir if doesn't exist
    F. keytool -importpass -alias elastic_user_password -keystore events-service.keystore -storetype pkcs12 # create a keystore and store the elastissearch 'elastic' user password from Step D.  Also, Enter keystore password that will be set in ad.es.client.keystore.password property
    
    G. vi $APPLICATION_HOME/conf/events-service-api-store.properties
       -ad.es.node.security.basic.auth.enabled=true # Enables basic Auth 
       -ad.es.client.basic.auth.enabled=true #Enables Java client to connect to the ElasticSearch cluster that has basic auth enabled  
       -ad.es.client.keystore.password= # Set the password from Step F
    
    BASH
  3. 次のように、単一ノードのセットアップ(通常はテストに使用)の Basic 認証を有効にします。

    For single node setup (for testing)

    A. vi $APPLICATION_HOME/conf/events-service-api-store.yml 
    B. Add 'discovery.type: single-node' property in nodeSettings section  
     - className: com.appdynamics.analytics.processor.elasticsearch.configuration.ElasticsearchConfigManagerModule
         properties:
            nodeSettings:
    C. vi $APPLICATION_HOME/conf/events-service-api-store.properties
          -ad.es.cluster.initial_master_nodes=  # set this as Empty 
          -ad.es.node.unicast.hosts= # set this as Empty 
    BASH
  4. トランスポート インターフェイスで TLS を有効にします。

    ad.es.node.security.tls.transport.enabled プロパティは、ノード間通信の TLS を有効または無効にします。

    次の点を確認します。

    その後で証明書を生成します。

    次のように CA 証明書とノード証明書を生成します。

    Generate certificate

    On any one node, Generate CA certificate by following step A to D
    A. export ES_JAVA_HOME=$APPLICATION_HOME/jre
    B. cd $APPLICATION_HOME/elasticsearch
    C. chmod +x bin/elasticsearch-certutil
    D. bin/elasticsearch-certutil ca  #Enter pwd: test123,  Should see file name elastic-stack-ca.p12
    E. Copy the same elastic-stack-ca.p12 CA cert to $APPLICATION_HOME/elasticsearch dir on every node in cluster.
    F. On every node in cluster, generate node certificate
       - cd $APPLICATION_HOME/elasticsearch
       - bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 --dns {node_hostname} #should see file elastic-certificates.p12 in current dir, node_hostname can be found by running hostname cmd
       - cp elastic-certificates.p12 config/cert
    BASH
  5. プロパティを次のように編集して、すべてのノードで TLS を有効にします。

    On every node, Enable TLS

    a. export ES_JAVA_HOME=$APPLICATION_HOME/jre
    b. vi $APPLICATION_HOME/conf/events-service-api-store.properties
       - ad.es.node.security.tls.transport.enabled=true #Set this property to enable TLS for transport
    c. cd $APPLICATION_HOME/elasticsearch
    d. chmod +x bin/elasticsearch-keystore
    e. bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password #Enter node certificate password from step 2.e
    f. bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password #Enter node certificate password from step 2.e
    BASH
  6. イベントサービスを開始します
HTTP の TLS を有効にする場合は、HTTP インターフェイスの TLS を有効にする前にイベントサービスを開始しないでください。

HTTP インターフェイスで TLS を有効にする

ad.es.node.security.tls.http.enabled プロパティは、イベントサービスと ElasticSearch 間の HTTP 通信の TLS を有効または無効にします。

次の点を確認します。

その後で次の手順を実行します。


  1. CA 証明書を生成したのと同じノードで HTTP 証明書を生成します。

    Generate HTTP certificate

    A. export ES_JAVA_HOME=$APPLICATION_HOME/jre
    B. cd $APPLICATION_HOME/elasticsearch
    C. chmod +x bin/elasticsearch-certutil 
    D. bin/elasticsearch-certutil http # This command generates a .zip file that contains certificates and keys to use with Elasticsearch and Kibana. Each folder contains a README.txt explaining how to use these files. 
    #Refer : https://www.elastic.co/guide/en/elasticsearch/reference/current/security-basic-setup-https.html
          1. When asked if you want to generate a CSR, enter n.
          2. When asked if you want to use an existing CA, enter y.
          3. Enter the path to your CA. This is the absolute path to the elastic-stack-ca.p12 file that you generated for your cluster.
          4. Enter the password for your CA.
          5. Enter an expiration value for your certificate. You can enter the validity period in years, months, or days. For example, enter 10000D for 10000D days.
          6. When asked if you want to generate one certificate per node, enter y.Each certificate will have its own private key, and will be issued for a specific hostname or IP address.
          7. When prompted, enter the name of the first node in your cluster. Use the same node name that you used when generating node certificates.
          8. Enter all hostnames (plus 'localhost') used to connect to your first node. These hostnames will be added as DNS names in the Subject Alternative Name (SAN) field in your certificate.List every hostname and variant used to connect to your cluster over HTTPS.
          9. Enter the IP addresses (plus 127.0.0.1) that clients can use to connect to your node.
          10. Repeat these steps for each additional node in your cluster.
    E. After generating a certificate for each of your nodes, enter a password for your private key when prompted.  
    F. Unzip the generated elasticsearch-ssl-http.zip file. This compressed file contains one directory for both Elasticsearch and Kibana. 
    /elasticsearch
    |_ README.txt
    |_ http.p12
    |_ sample-elasticsearch.yml
    
    /kibana
    |_ README.txt
    |_ elasticsearch-ca.pem
    |_ sample-kibana.yml
    
    G. On every node in your cluster, copy the relevant http.p12 certificate to the $APPLICATION_HOME/elasticsearch/config/cert directory.
    H.Generate CA cert client-ca.cer, this is needed by events-service
      openssl pkcs12 -in elastic-certificates.p12 -cacerts -nokeys -chain > client-ca.cer
    I.On every node in your cluster, copy client-ca.cer at $APPLICATION_HOME/conf/security    
    
    BASH
  2. 次のようにプロパティを編集して、すべてのノードで TLS を有効にします。

    On every node

    A. export ES_JAVA_HOME=/home/ec2-user/appdynamics/platform/product/events-service/processor/jre
    B. cd $APPLICATION_HOME/elasticsearch
    C. chmod +x bin/elasticsearch-keystore
    D. bin/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password #Enter node certificate password from step 2.D
    E. bin/elasticsearch-keystore add xpack.security.http.ssl.truststore.secure_password #Enter node certificate password from step 2.D
    
    I. vi $APPLICATION_HOME/conf/events-service-api-store.properties 
      - ad.es.node.security.tls.http.enabled=true # Set the property to enable TLS for HTTP
      - ad.es.client.tls.enabled.http.port=true # Enable Java ES client to connect over HTTPS
    BASH
  3. イベントサービスを開始します

TLS が有効になっているか確認する

イベントサービスで Elastic Search クラスタと通信できるようになり、これは events-service-api-store.log ファイルで確認できます。

Logs

[2023-03-25T15:11:19,192+05:30]  [INFO ]  [main]  [c.a.a.p.e.n.s.ElasticsearchDependencyModule]  Elasticsearch healthy, it should now be responsive.
[2023-03-25T15:11:19,194+05:30]  [INFO ]  [main]  [c.a.a.p.e.index.MetaDataIndexCreator]  Creating metaData indices...
CODE

次のように、HTTP で TLS が有効になっているか確認します。

Verify if TLS is enabled on HTTP

❯ curl -X GET "https://localhost:9200" -k -u elastic:pass123
{
  "name" : "ATKUMAR3-M-2344",
  "cluster_name" : "appdynamics-events-service-cluster",
  "cluster_uuid" : "eLk8ZXUDTe2yKTt-AChDLg",
  "version" : {
    "number" : "8.4.3",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "42f05b9372a9a4a470db3b52817899b99a76ee73",
    "build_date" : "2022-10-04T07:17:24.662462378Z",
    "build_snapshot" : false,
    "lucene_version" : "9.3.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}
C#