kjaggann commented on a change in pull request #6763:
URL: https://github.com/apache/pulsar/pull/6763#discussion_r416814675



##########
File path: site2/docs/security-encryption.md
##########
@@ -78,18 +78,20 @@ class RawFileKeyReader implements CryptoKeyReader {
         return keyInfo;
     }
 }
-PulsarClient pulsarClient = PulsarClient.create("http://localhost:8080";);
 
-ProducerConfiguration prodConf = new ProducerConfiguration();
-prodConf.setCryptoKeyReader(new RawFileKeyReader("test_ecdsa_pubkey.pem", 
"test_ecdsa_privkey.pem"));
-prodConf.addEncryptionKey("myappkey");
+PulsarClient pulsarClient = 
PulsarClient.builder().serviceUrl("pulsar://localhost:6650").build();
 
-Producer producer = 
pulsarClient.createProducer("persistent://my-tenant/my-ns/my-topic", prodConf);
+Producer producer = pulsarClient.newProducer()
+                .topic("persistent://my-tenant/my-ns/my-topic")
+                .addEncryptionKey("myappkey")

Review comment:
       I used secured  AES key generated from this method
        Key key;
                SecureRandom rand = new SecureRandom();
                KeyGenerator generator = KeyGenerator.getInstance("AES");
                generator.init(256, rand);
                key = generator.generateKey();
   and  created a producer
   Producer<byte[]> producer = client.newProducer()
                                        
.topic("persistent://my-tenant/my-namespace/my-topic-1")
                                        .cryptoKeyReader(new 
RawFileKeyReader("src/main/resources/test_ecdsa_pubkey.pem", 
"src/main/resources/test_ecdsa_privkey.pem"))
                                        .addEncryptionKey("key")
                                        .enableBatching(false)
                                        .create();
   
   But i got this exception
   org.apache.pulsar.client.api.PulsarClientException: 
java.util.concurrent.ExecutionException: 
org.apache.pulsar.client.api.PulsarClientException: 
java.lang.NoSuchMethodError: 'org.apache.pulsar.shade.io.netty.buffer.ByteBuf 
org.apache.pulsar.client.api.MessageCrypto.encrypt(java.util.Set, 
org.apache.pulsar.client.api.CryptoKeyReader, java.util.function.Supplier, 
org.apache.pulsar.shade.io.netty.buffer.ByteBuf)'
   
   
------------------------------------------------------------------------------------------------------------------
   I followed the document 
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to