Skip to content

Instantly share code, notes, and snippets.

@eransharv
Created June 14, 2017 08:31
Show Gist options
  • Save eransharv/9de8e94faae5bde70dfcdfa7d8e6157b to your computer and use it in GitHub Desktop.
Save eransharv/9de8e94faae5bde70dfcdfa7d8e6157b to your computer and use it in GitHub Desktop.
java Redisson redis client example using SSL
Config config = new Config();
config.useSingleServer()
.setAddress("rediss://redis-10928.c10.us-east-1-3.ec2.cloud.redislabs.com:10928")
.setSslKeystore(URI.create("file:/C:/Devel/projects/redisson/JedisSSL.p12"))
.setSslKeystorePassword("test1234")
.setSslTruststore(URI.create("file:/C:/Devel/projects/redisson/keystore.jks"))
.setSslTruststorePassword("test1234");
RedissonClient redisson = Redisson.create(config);
RBucket<String> bucket = redisson.getBucket("foo");
bucket.set("1");
System.out.println("bucket " + bucket.get());
@eransharv
Copy link
Author

eransharv commented Jun 14, 2017

Download the certificates through the UI. The zip contains 3 files:

  1. garantia_ca.pem
  2. garantia_user.crt
  3. garantia_user_private.key

Create p12 file, using the crt file and the private key file:

> openssl pkcs12 -export -in garantia_user.crt -inkey garantia_user_private.key -out JedisSSL.p12

Create the jks file, using the pem file:

> keytool -import -alias bundle -trustcacerts -file garantia_ca.pem -keystore keystore.jks

@bensagi
Copy link

bensagi commented Oct 11, 2023

can I use the truststore without the keystore?
im using redis instance managed by googlecloud which provided only the .pem file without the .cert and .key files.
in this case, is truststore definition only should work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment