public void configure() throws Exception {
Endpoint createEndpoint = cdcHelper.setupSSLConext(context);
from("{{timerOnce}}").process(consumerCreate)
.to(createEndpoint); // calling kafka consumer
}
}
public Endpoint setupSSLConext(CamelContext camelContext) throws Exception {
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
// Change this path to point to your truststore/keystore as jks files
keyStoreParameters.setResource("kafka.client.truststore.jks");
keyStoreParameters.setPassword("123456");
KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
keyManagersParameters.setKeyStore(keyStoreParameters);
keyManagersParameters.setKeyPassword("123456");
TrustManagersParameters trustManagersParameters = new TrustManagersParameters();
trustManagersParameters.setKeyStore(keyStoreParameters);
SSLContextParameters sslContextParameters = new SSLContextParameters();
sslContextParameters.setKeyManagers(keyManagersParameters);
sslContextParameters.setTrustManagers(trustManagersParameters);
HttpComponent httpComponent = camelContext.getComponent("https4", HttpComponent.class);
httpComponent.setSslContextParameters(sslContextParameters);
// This is important to make your cert skip CN/Hostname checks
httpComponent.setX509HostnameVerifier(new X509HostnameVerifier() {
@Override
public void verify(String s, SSLSocket sslSocket) throws IOException {
}
@Override
public void verify(String s, X509Certificate x509Certificate) throws SSLException {
}
@Override
public void verify(String s, String[] strings, String[] strings1) throws SSLException {
}
@Override
public boolean verify(String s, SSLSession sslSession) {
// I don't mind just return true for all or you can add your own logic
return true;
}
});
return httpComponent.createEndpoint("https://XX.XX.X.XXX/consumers/");
}
My requirement is to connect the Kafka consumer through the SSL with Spring boot and Camel, for that, I have written the below code but I'm facing an error like Caused by sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target this, anyone please help me how to resolve this error.
public class Testing {
@Bean
SSLContextParameters sslContextParameters(){
KeyStoreParameters store = new KeyStoreParameters();
store.setResource("kafka.client.truststore.jks");
store.setPassword("123456");
TrustManagersParameters trust = new TrustManagersParameters();
trust.setKeyStore(store);
SSLContextParameters parameters = new SSLContextParameters();
parameters.setTrustManagers(trust);
return parameters;
}
}
In another file, I'm calling router with sslContextParameters parameter
@Autowired
SSLContextParameters params;
@Override
public void configure() throws Exception {
from("{{timerOnce}}").process(consumerCreate).to(
"{{conumserRoute}}{{groupName}}?sslContextParameters=params");
}
I am running in issues with absolute and relative path when trying to pick file from remote location. Can someone please help with this issue? I am using Camel v3.0.1. I have a SFTP location sftp://my.sftpserver.com:22. My default home directory is as below:
sftp> pwd
Remote working directory: /Distribution/dor/Rec_Sales/Comp
I want to change directory to /Distribution/dor/modlpool_daily_L5
to pick files.
However I am getting error when trying absolute path: //Distribution/dor/modlpool_daily_L5
28 Oct 2020 12:18:10,432 ERROR [Camel (camelContext) thread #853 - sftp://my.sftpserver.com:22//Distribution/dor/modlpool_daily_L5/] StopRouteExternalExceptionProcessor:34 - ERROR MESSEGE: Cannot list directory: Distribution/dor/modlpool_dail
y_L5
Also when trying relative path: ../../modlpool_daily_L5/
28 Oct 2020 13:14:10,812 ERROR [Camel (camelContext) thread #1148 - sftp://my.sftpserver.com:22/../../modlpool_daily_L5/] StopRouteExternalExceptionProcessor:34 - ERROR MESSEGE: Cannot retrieve file: ../../modlpool_daily_L5/test.txt
org.apache.camel.component.salesforce.api.SalesforceException: {errors:[{"errorCode":"invalid_grant","message":"Login error code:[invalid_grant] description:[audience is invalid]","fields":null}],statusCode:400}
after the component sits for a while, using JWT Bearer Token flow with a Connected App with pre-authorized users by profile. Can't find a way to make sure the token is refreshed or how to bust the cache and reauthenticate.