Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-6989

Backup Client Fails When Specifying Incorrect Protocol for Base URL

      If you perform a backup with the backup client, and you specify http:// for the base URL rather than https:// (if Stash is configured to expect HTTPS), then the backup will fail with the following error:

      dlahn@fecru35pg:/opt/atlassian/stash-backup-client-1.6.0$ sudo java -jar stash-backup-client.jar
      2015-01-14 14:00:40,324 INFO         Initializing
      2015-01-14 14:00:43,611 ERROR        A backup could not be created. Reason: Unable to determine the current character, it is not a string, number, array, or object
      
      The current character read is '<' with an int value of 60
      Unable to determine the current character, it is not a string, number, array, or object
      line number 1
      index number 0
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
      ^
      
      groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
      
      The current character read is '<' with an int value of 60
      Unable to determine the current character, it is not a string, number, array, or object
      line number 1
      index number 0
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
      ^
      	at groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:216) ~[groovy-all-2.3.6.jar:2.3.6]
      	at groovy.json.internal.JsonParserCharArray.decodeValue(JsonParserCharArray.java:166) ~[groovy-all-2.3.6.jar:2.3.6]
      	... 13 more frames available in the log file
      

      This error message should be amended by provide more details about where the problem is coming from. (i.e. the base URL doesn't match.)

            [BSERV-6989] Backup Client Fails When Specifying Incorrect Protocol for Base URL

            The backup client 1.9.1 and subsequent versions will include clearer error messages when the base URL is specified with an incorrect protocol (that is http instead of https and vice versa). However the error, as specified in the issue's description, could not reproduced. Hence this issue will be closed as 'Cannot reproduce' for now.

            Please reopen this issue if you are able to reproduce it, with detailed steps and the versions of all the components involved (Stash, Stash Backup Client, proxies, Java version, etc.).

            Pierre-Etienne Poirot (Inactive) added a comment - The backup client 1.9.1 and subsequent versions will include clearer error messages when the base URL is specified with an incorrect protocol (that is http instead of https and vice versa). However the error, as specified in the issue's description, could not reproduced. Hence this issue will be closed as 'Cannot reproduce' for now. Please reopen this issue if you are able to reproduce it, with detailed steps and the versions of all the components involved (Stash, Stash Backup Client, proxies, Java version, etc.).

            I was not able to reproduce the same error when configuring Apache in front of Stash. The setup was:

            • Apache 2.4.10, with mod_proxy (see the configuration below),
            • Stash 3.3.0 (see the configuration below).

            Apache was used to perform SSL termination and forwards the request to Stash over plain HTTP. If queried over plain HTTP on the SSL port, Apache responds with a clear error message describing the problem:

            % curl -i http://localhost:8081/
            HTTP/1.1 400 Bad Request
            Date: Thu, 21 May 2015 06:24:33 GMT
            Server: Apache/2.4.10 (Ubuntu) OpenSSL/1.0.1f
            Content-Length: 362
            Connection: close
            Content-Type: text/html; charset=iso-8859-1
            
            <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
            <html><head>
            <title>400 Bad Request</title>
            </head><body>
            <h1>Bad Request</h1>
            <p>Your browser sent a request that this server could not understand.<br />
            Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
             Instead use the HTTPS scheme to access this URL, please.<br />
            </p>
            </body></html>
            

            It matches the symptoms on the issue's description (the backup client specifies a base URL starting with http:// where the server expects https://). However the error thrown by the backup client is not the same:

            /Atlassian/backup-client/1.6.0 % java -Dstash.password="admin" -Dstash.user="admin" -Dstash.baseUrl="http://localhost:8081" -Dstash.home=/Atlassian/stash-homes/default -Dbackup.home=. -jar stash-backup-client.jar
            2015-05-21 16:26:28,531 INFO         Initializing
            2015-05-21 16:26:29,807 ERROR        A backup could not be created. Reason: The Stash version could not be verified; the server returned 400 Bad Request. Backup/restore is only supported by Stash 2.7.0 and later.
            
            com.atlassian.stash.internal.backup.client.BackupException: The Stash version could not be verified; the server returned 400 Bad Request. Backup/restore is only supported by Stash 2.7.0 and later.
            	at com.atlassian.stash.internal.backup.client.RestStashService.handleVersionQueryFailure(RestStashService.groovy:339) ~[stash-backup-client.jar:1.6.0]
            	at com.atlassian.stash.internal.backup.client.RestStashService.getVersion(RestStashService.groovy:183) ~[stash-backup-client.jar:1.6.0]
            	... 7 more frames available in the log file
            
            Configuration
            • Apache:
            LoadModule authn_core_module /usr/lib/apache2/modules/mod_authn_core.so
            LoadModule authz_core_module /usr/lib/apache2/modules/mod_authz_core.so
            LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
            LoadModule mpm_prefork_module /usr/lib/apache2/modules/mod_mpm_prefork.so
            LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
            LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
            LoadModule headers_module    /usr/lib/apache2/modules/mod_headers.so
            LoadModule deflate_module    /usr/lib/apache2/modules/mod_deflate.so
            LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
            
            ServerName localhost
            Listen 8081 https
            PidFile http.pid
            
            <VirtualHost *:8081>
                ServerName localhost
                SSLEngine on
                SSLCertificateFile "test.crt"
                SSLCertificateKeyFile "test.key"
            </VirtualHost>
            
            SSLCipherSuite HIGH:!aNULL:!MD5
            
            <Proxy "*">
            	Require host localhost
            </Proxy>
            
            ProxyPass "/" "http://localhost:7990/"
            ProxyPassReverse "/" "http://localhost:7990/"
            
            • Stash (connector's configuration in Tomcat's server.xml):
                   <Connector port="7990" protocol="HTTP/1.1"
                               proxyPort="8081"
                               scheme="https"
                               secure="true"
                               proxyName="localhost"
                               connectionTimeout="20000"
                               useBodyEncodingForURI="true"
                               compression="on"
                               compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript" />
            

            Pierre-Etienne Poirot (Inactive) added a comment - - edited I was not able to reproduce the same error when configuring Apache in front of Stash. The setup was: Apache 2.4.10, with mod_proxy (see the configuration below), Stash 3.3.0 (see the configuration below). Apache was used to perform SSL termination and forwards the request to Stash over plain HTTP. If queried over plain HTTP on the SSL port, Apache responds with a clear error message describing the problem: % curl -i http://localhost:8081/ HTTP/1.1 400 Bad Request Date: Thu, 21 May 2015 06:24:33 GMT Server: Apache/2.4.10 (Ubuntu) OpenSSL/1.0.1f Content-Length: 362 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> </head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> Reason: You're speaking plain HTTP to an SSL-enabled server port.<br /> Instead use the HTTPS scheme to access this URL, please.<br /> </p> </body></html> It matches the symptoms on the issue's description (the backup client specifies a base URL starting with http:// where the server expects https:// ). However the error thrown by the backup client is not the same: /Atlassian/backup-client/1.6.0 % java -Dstash.password="admin" -Dstash.user="admin" -Dstash.baseUrl="http://localhost:8081" -Dstash.home=/Atlassian/stash-homes/default -Dbackup.home=. -jar stash-backup-client.jar 2015-05-21 16:26:28,531 INFO Initializing 2015-05-21 16:26:29,807 ERROR A backup could not be created. Reason: The Stash version could not be verified; the server returned 400 Bad Request. Backup/restore is only supported by Stash 2.7.0 and later. com.atlassian.stash.internal.backup.client.BackupException: The Stash version could not be verified; the server returned 400 Bad Request. Backup/restore is only supported by Stash 2.7.0 and later. at com.atlassian.stash.internal.backup.client.RestStashService.handleVersionQueryFailure(RestStashService.groovy:339) ~[stash-backup-client.jar:1.6.0] at com.atlassian.stash.internal.backup.client.RestStashService.getVersion(RestStashService.groovy:183) ~[stash-backup-client.jar:1.6.0] ... 7 more frames available in the log file Configuration Apache: LoadModule authn_core_module /usr/lib/apache2/modules/mod_authn_core.so LoadModule authz_core_module /usr/lib/apache2/modules/mod_authz_core.so LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so LoadModule mpm_prefork_module /usr/lib/apache2/modules/mod_mpm_prefork.so LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so ServerName localhost Listen 8081 https PidFile http.pid <VirtualHost *:8081> ServerName localhost SSLEngine on SSLCertificateFile "test.crt" SSLCertificateKeyFile "test.key" </VirtualHost> SSLCipherSuite HIGH:!aNULL:!MD5 <Proxy "*" > Require host localhost </Proxy> ProxyPass "/" "http: //localhost:7990/" ProxyPassReverse "/" "http: //localhost:7990/" Stash (connector's configuration in Tomcat's server.xml): <Connector port= "7990" protocol= "HTTP/1.1" proxyPort= "8081" scheme= "https" secure= "true" proxyName= "localhost" connectionTimeout= "20000" useBodyEncodingForURI= "true" compression= "on" compressableMimeType= "text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript" />

              pepoirot Pierre-Etienne Poirot (Inactive)
              dlahn David Lahn (Inactive)
              Affected customers:
              1 This affects my team
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: