Exist: [BUG] Command line scripts for backup/restore do not support SSL

Created on 27 May 2020  路  10Comments  路  Source: eXist-db/exist

Describe the bug
Using the shell scripts provided by eXist (backup.sh/backup.bat) it is not possible to backup or restore from/to an eXist server with SSL, as the flag -ossl-enable is ignored and an error (org.xmldb.api.base.XMLDBException: HTTP server returned unexpected status: Bad Request) is returned. @adamretter wrote on slack:

I took a look at the code. It doesn't look like it will set the SSL property from the Backup/Restore entry/points whereas it does for the client

Expected behavior
I expected to use a script like this:

backup --restore local\path\__contents__.xml --user admin --password foobar -ouri=xmldb:exist://exist.host.de/exist/xmlrpc -ossl-enable=true

To Reproduce

Try to connect to a remote eXist server with SSL using the provided backup/restore scripts (see shell example above).

Context (please always complete the following information):

  • OS: Windows 7
  • eXist-db version: 4.7.1
  • Java Version: JRE build 1.8.0_241-b07
triage

Most helpful comment

I'm going to work on this issue and will try to fix it

All 10 comments

If you give us some pointers on what to do, we could _maybe_ provide a fix. I'm interested in seeing this fixed, since this bug breaks part of our workflow.

@zed-g if you look in the exist-core module at how SSL is enabled in org.exist.client.InteractiveClient and then apply the same kind of idea to org.exist.backup.Main

I'm going to work on this issue and will try to fix it

So I think I've found a solution to the problem. As you said, I have oriented myself to the client class and set the SSL Property in the Main.class explicitly in the process() function:

 Optional.ofNullable(arguments.get(optionArg)).ifPresent(options -> {
        options.forEach(properties::setProperty);

        if(options.containsKey(SSL_ENABLE)){
            properties.setProperty(SSL_ENABLE, options.get(SSL_ENABLE));
        }
    });

And then I set the Property for the database:
database.setProperty(SSL_ENABLE, properties.getProperty(SSL_ENABLE));

This worked for me and the command mentioned in the description threw no Errors.

@MisterZurk0n Can you send a PR so we can take a look?

Sorry, I'm a first time contributor and pretty new to all of this. I haven't written a test for that yet. I don't want to send a PR without a proper one. Do you have a suggestion what my tests should cover? Or how they should look like?

Hey @MisterZurk0n don't worry, we are happy you want to contribute :-)

I think this is a very hard thing to test as it requires sending arguments via the command line and then ensuring that an SSL connection can be established. eXist-db does not have any integration tests which are quite so "end-to-end".

For this small change I would suggest to open a PR without the test, hopefully through careful review and some manual we can make sure it's ok ;-)

Thank you, for your fast response :) I send you the PR

@MisterZurk0n Thanks again for your fix!
@adamretter Thanks for your quick and helpful assistance! Do you want me to extend the documentation at https://github.com/eXist-db/documentation/blob/master/src/main/xar-resources/data/backup/backup.xml for the new --use-ssl flag?

@zed-g Yes, please, that would be great! Thanks!

Was this page helpful?
0 / 5 - 0 ratings