简体   繁体   English

如何使用DataStax Java驱动程序设置Cassandra客户端到节点加密?

[英]How to set up Cassandra client-to-node encryption with the DataStax Java driver?

I've set up node-to-node encryption on my Cassandra cluster. 我在我的Cassandra集群上设置了节点到节点加密。 Now I want to set up client-to-node. 现在我想建立客户端到节点。 According to this documentation , it should be as easy as taking the SSL certificate of my client and importing it into every node's truststore. 根据此文档 ,它应该像获取客户端的SSL证书并将其导入每个节点的信任库一样简单。 I don't have such a certificate yet but this is not my question. 我还没有这样的证书,但这不是我的问题。

Since my client is using the DataStax Java driver, it seems that in order to enable SSL from the client side, when I am building the Cluster I should use the withSSL() method to enable SSL. 由于我的客户端使用DataStax Java驱动程序,似乎为了从客户端启用SSL,当我构建Cluster我应该使用withSSL()方法来启用SSL。 Okay, but what else do I need to do? 好的,但我还需要做什么? I am not familiar with JSSE so I don't know what else is necessary. 我不熟悉JSSE,所以我不知道还有什么必要。 Is the SSL communication two-way, ie does the driver need to have access to the SSL certificates of each node in the cluster? SSL通信是双向的,即驱动程序是否需要访问群集中每个节点的SSL证书?

  1. Create the certificates [1]. 创建证书[1]。

  2. Enable client-node encryption in cassandra.yaml settings [2]. 在cassandra.yaml设置中启用客户端节点加密[2]。

  3. Add SSL support to your client. 向您的客户端添加SSL支持。 There is an excellent datastax blog on with sample code for setting up the SSL connection in your client [3]. 有一个优秀的datastax博客,其中包含用于在客户端设置SSL连接的示例代码[3]。

  4. A cert for your client. 为您的客户提供的证书。 From what I can tell, it seems like you should be able to use the same keystore and trusture from [1] for the java client to use. 据我所知,您似乎应该能够使用[1]中的相同密钥库和信任来供Java客户端使用。 Per [4], I know you need a pcks12 style PEM file to use cqlsh. Per [4],我知道你需要一个pcks12风格的PEM文件才能使用cqlsh。

Also, [4] provides a barebones example of a client connecting to a cassandra cluster over SSL. 此外,[4]提供了通过SSL连接到cassandra集群的客户端的准系统示例。 [5] is an okay read for examples of cert creation for the cluster nodes and client. [5]是关于群集节点和客户端的证书创建示例的正确读物。

  1. [6] is the best example I've found of creating the certificates. [6]是我发现创建证书的最好例子。

NB If you wish to use enterprise strength encryption, you'll need to enable the Java Cryptography Extension . 注意如果您希望使用企业级加密,则需要启用Java Cryptography Extension For legal reasons, only relatively weak encryption is supported by the java that is shipped. 出于法律原因,只提供相对较弱的加密。 Cassandra and your client will likely complain if you try to use 256 bit encryption without the JCE enabled. 如果您尝试在未启用JCE的情况下使用256位加密,Cassandra和您的客户可能会抱怨。 Do this for both the client and server machines: 客户端和服务器计算机执行此操作:

  1. Download http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html 下载http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
  2. Unzip the package 解压缩包
  3. Copy the two policy jars into your JAVA_HOME, overwriting the two jars that are already there: 将两个策略jar复制到JAVA_HOME中,覆盖已经存在的两个jar:

    [user@host UnlimitedJCEPolicy]$ ls local_policy.jar README.txt US_export_policy.jar [user@host UnlimitedJCEPolicy]$ export JAVA_HOME="$( readlink -f "$( which java )" | sed "s:bin/.*$::" )" [use@host UnlimitedJCEPolicy]$ echo $JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/ [user@host UnlimitedJCEPolicy]$ cp -v *.jar $JAVA_HOME/lib/security/

  4. Restart cassandra and the client 重启cassandra和客户端

[1] http://www.datastax.com/documentation/cassandra/2.0/cassandra/security/secureSSLCertificates_t.html [1] http://www.datastax.com/documentation/cassandra/2.0/cassandra/security/secureSSLCertificates_t.html

[2] http://www.datastax.com/documentation/cassandra/2.0/cassandra/security/secureSSLClientToNode_t.html [2] http://www.datastax.com/documentation/cassandra/2.0/cassandra/security/secureSSLClientToNode_t.html

[3] http://www.datastax.com/dev/blog/accessing-secure-dse-clusters-with-cql-native-protocol [3] http://www.datastax.com/dev/blog/accessing-secure-dse-clusters-with-cql-native-protocol

[4] https://github.com/PatrickCallaghan/datastax-ssl-example [4] https://github.com/PatrickCallaghan/datastax-ssl-example

[5] http://www.datastax.com/dev/blog/accessing-secure-dse-clusters-with-cql-native-protocol [5] http://www.datastax.com/dev/blog/accessing-secure-dse-clusters-with-cql-native-protocol

[6] http://techdocs.acunu.com.s3.amazonaws.com/v5.0/admin/security/ssl.html [6] http://techdocs.acunu.com.s3.amazonaws.com/v5.0/admin/security/ssl.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM