aminedev
aminedev

Reputation: 323

How to use Wagon maven plugin with FTPS

I'm using the below configuration to upload files to a remote server through FTPS protocol :

<extensions>
    <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ftp</artifactId>
        <version>3.0.0</version>
    </extension>
</extensions>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>wagon-maven-plugin</artifactId>
    <version>1.0-beta-3</version>
    <configuration>
        <skip>true</skip>
        <url>ftps://username:password@ip_address</url>
        <fromDir>${project.build.directory}</fromDir>
        <toDir>.</toDir>
    </configuration>
    <executions>
        <execution>
            <id>upload</id>
            <phase>deploy</phase>
            <goals>
                <goal>upload</goal>
            </goals>
        </execution>
    </executions>
</plugin>

If i use only FTP instead of FTPS in the url parameter the goal is executed successfully and data are sent to the remote server, but when I use FTPS for security reasons, I get the below error :

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload (default-cli) on project XXX: The parameters 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload are missing or invalid
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload are missing or invalid
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:641)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:594)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)

'

Upvotes: 3

Views: 807

Answers (3)

mcwayliffe
mcwayliffe

Reputation: 426

I ran into a similar issue recently. In my case, because my FTP server's certificate was self-signed, I did have to disable endpointChecking:

<endpointChecking>false</endpointChecking>

However, it also appears that the Wagon FTP provider does not support encrypted data connections. I see no mention in the code of

FTPSClient.execProt("P");

Since I am running vsftpd as my FTP server, it was necessary to allow unencrypted data connections server-side as well:

# vsftpd.conf 
...
force_local_data_ssl=NO

In my case, the use of the <implicit> setting was counter-productive, as vsftpd by default negotiates the port rather than using the implicit one.

Upvotes: 0

aminedev
aminedev

Reputation: 323

I solved the issue using the below configuration :

Pom.xml :

 <extensions>
    <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ftp</artifactId>
        <version>3.0.0</version>
    </extension>
</extensions>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>wagon-maven-plugin</artifactId>
    <version>1.0-beta-3</version>
    <configuration>
        <serverId>serverid</serverId>
        <skip>true</skip>
        <url>ftps://ip_address:port</url>
        <fromDir>${project.build.directory}</fromDir>
        <toDir>.</toDir>
    </configuration>
    <executions>
        <execution>
            <id>upload</id>
            <phase>deploy</phase>
            <goals>
                <goal>upload</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Settings.xml :

   <server>
        <id>serverid</id>
        <username>XXXXXX</username>
        <password>XXXXXX</password>
        <configuration>
            <endpointChecking>false</endpointChecking>
            <securityProtocol>TLS</securityProtocol> 
            <implicit>true</implicit>
            <passiveMode>true</passiveMode>
        </configuration>
    </server>

Thank you !

Upvotes: 2

Mark Bramnik
Mark Bramnik

Reputation: 42501

I don't have an ability to test the answer in my environment, but it seems that Wagon supports FTPS mode with FTP provider.

The documentation however states that you should configure the securityProtocol to be FTPS for this, since the default is TLS.

// settings.xml
<server>
    <id>ftp.server.id</id>
    <username>username</username>
    <password>password</password>
    <configuration>
         ....
         <securityProtocol>FTPS</securityProtocol>   <-- !!!
    </configuration>
</server>

Upvotes: 0

Related Questions