Camel-sftp disable host verification globally

北战南征 提交于 2021-01-28 05:05:15

问题


I use Camel DSL route definition:

@Component
public class UploadRoutesDefinition extends RouteBuilder {
  ...
  @Override
    public void configure() throws Exception {

    ```
        from(String.format("sftp://%s@%s:%d/%s?password=%s&delete=true&readLock=changed&delay=%s"
        ...

When I put file into sftp folder I see following logs:

20/03/2018 14:02:4420.03.18 14:02:44.193 [Camel (My_Service) thread #3 - seda://parsed_csv] INFO  o.a.c.c.file.remote.SftpOperations - Known host file not configured, using user known host file: /home/gradle/.ssh/known_hosts
20/03/2018 14:02:4420.03.18 14:02:44.300 [Camel (MIS_UploadService) thread #3 - seda://parsed_csv] WARN  o.a.c.c.file.remote.SftpOperations - JSCH -> Permanently added 'sftp' (RSA) to the list of known hosts.
20/03/2018 14:02:4420.03.18 14:02:44.300 [Camel (MIS_UploadService) thread #3 - seda://parsed_csv] WARN  o.a.c.c.file.remote.SftpOperations - Server asks for confirmation (yes|no): /home/gradle/.ssh/known_hosts does not exist.
20/03/2018 14:02:44Are you sure you want to create it?. Camel will answer no.
```

I want to disable host verification.

Looks like adding &useUserKnownHostsFile=false to the path resolves my error. But I have a lot of route definitions and I don't like to add this suffix to each URL. Can I disable this verification globally?


回答1:


You cannot configure this globally. But as its java code its easy to use Camel's property placeholder to have a global ftp url you can use as base, or in your Camel route its also just Java code, so the string formatter you do, can use a base string that has the option turned on you then use with string concat etc.



来源:https://stackoverflow.com/questions/49425742/camel-sftp-disable-host-verification-globally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!