title: Zookeeper TLS setup using PEM file
body: <p>I see zookeeper 3.5.5 has a option to pass in .PEM files to set up TLS encryption. 
  I have server certificate.pem and privatekey.pem generated using openssl and set zookeper config as below</p>
  
  <pre><code>tickTime=2000
  dataDir=/var/lib/zookeeper
  clientPort=2181
  initLimit=5
  syncLimit=2
  server.1=10.247.246.3:2888:3888
  server.2=10.247.246.4:2888:3888
  server.3=10.247.246.5:2888:3888
  
  sslQuorum=true
  serverCnxnFactory=org.apache.zookeeper.server.NettyServerCnxnFactory
  ssl.quorum.keyStore.location=/tmp/zoo/apache-zookeeper-3.5.7-bin/bin/certs/test/certWithPrivateKey.pem
  ssl.quorum.keyStore.password=********
  ssl.quorum.trustStore.location=/path/to/ca/ca-cert.pem
  ssl.quorum.trustStore.password=******
  ssl.hostnameVerification=false
  ssl.quorum.hostnameVerification=false
  ssl.keyStore.type=PEM
  ssl.quorum.keyStore.type=PEM
  ssl.trustStore.type=PEM
  ssl.quorum.trustStore.type=PEM
  </code></pre>
  
  <p>But I get this error when starting zookeeper. </p>
  
  <pre><code>org.apache.zookeeper.common.X509Exception$SSLContextException: Failed to create KeyManager
          at org.apache.zookeeper.common.X509Util.createSSLContextAndOptionsFromConfig(X509Util.java:350)
          at org.apache.zookeeper.common.X509Util.createSSLContextAndOptions(X509Util.java:328)
          at org.apache.zookeeper.common.X509Util.createSSLContextAndOptions(X509Util.java:282)
          at org.apache.zookeeper.common.X509Util.getDefaultSSLContextAndOptions(X509Util.java:262)
          at org.apache.zookeeper.common.X509Util.createSSLSocket(X509Util.java:517)
          at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:672)
          at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:748)
          at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:776)
          at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:958)
          at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:1425)
  Caused by: org.apache.zookeeper.common.X509Exception$KeyManagerException: java.io.IOException: overrun, bytes = 111
          at org.apache.zookeeper.common.X509Util.createKeyManager(X509Util.java:447)
          at org.apache.zookeeper.common.X509Util.createSSLContextAndOptionsFromConfig(X509Util.java:348)
          ... 9 more
  Caused by: java.io.IOException: overrun, bytes = 111
          at java.base/javax.crypto.EncryptedPrivateKeyInfo.&lt;init&gt;(EncryptedPrivateKeyInfo.java:95)
          at org.apache.zookeeper.util.PemReader.loadPrivateKey(PemReader.java:154)
          at org.apache.zookeeper.util.PemReader.loadPrivateKey(PemReader.java:142)
          at org.apache.zookeeper.util.PemReader.loadKeyStore(PemReader.java:103)
          at org.apache.zookeeper.common.PEMFileLoader.loadKeyStore(PEMFileLoader.java:50)
          at org.apache.zookeeper.common.X509Util.loadKeyStore(X509Util.java:400)
          at org.apache.zookeeper.common.X509Util.createKeyManager(X509Util.java:436)
  
  </code></pre>
  
  <p>Note : I checked zookeeper source code <a href="https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/util/PemReader.java" rel="nofollow noreferrer">PEMReader.java</a>, as the code was expecting key and cert to be in PEM file .
  I have created certWithPrivate.pem by concatenating certificate.pem and privatekey.pem (cat certificate.pem privatekey.pem > certWithPrivate.pem)</p>
  
  <p>Any ideas ? </p>