Introduction
When attempting to install certain packages using yum or dnf, you might encounter a 400 error from Tomcat, particularly with special characters in the package name.
For example:
dnf install passt-selinux MIRROR] passt-selinux-0^20240806.gee36266-2.el9.noarch.rpm: Status code: 400 for https://ART_URL/centos-stream/9-stream/AppStream/x86_64/os/Packages/passt-selinux-0^20240806.gee36266-2.el9.noarch.rpm
This error occurs because yum/dnf does not URL-encode the ^ character in the URL, and by default, Tomcat rejects requests containing unencoded special characters like ^.
Cause
Tomcat, the servlet container used by Artifactory, restricts certain special characters in URLs by default.
You can see the following message in tomcat-catalina.log or console.log file
java.lang.IllegalArgumentException: Invalid character found in the request target [/artifactory/centos-stream/9-stream/AppStream/x86_64/os/Packages/passt-0^20240806.gee36266-2.el9.x86_64.rpm ]. The valid characters are defined in RFC 7230 and RFC 3986
However, you can configure Tomcat to allow specific characters by modifying the relaxedPathChars and relaxedQueryChars attributes.
By default, Artifactory's Tomcat allows square brackets [ ] as special characters in both the path and query strings. You can confirm this in the server.xml file located at:
/opt/jfrog/artifactory/app/artifactory/tomcat/conf/server.xml
A typical configuration might look like this:
<Connector port="8081" sendReasonPhrase="false" relaxedPathChars='[]' relaxedQueryChars='[]' maxThreads="200" />
Resolution
Allowing the ^ Character
To resolve the issue, you'll need to update the relaxedPathChars attribute to include the ^ character, while retaining the default [] characters. Since the ^ appears in the path (before the ? in the URL), you only need to modify relaxedPathChars.
Update the Configuration in Artifactory's system.yaml
Modify the system.yaml configuration file to include ^ in the relaxedPathChars attribute:
artifactory: port: 8081 tomcat: connector: relaxedPathChars: '^[]'
Resulting server.xml entry:
After making this change, the corresponding server.xml entry should look like this:
<Connector port="8081" sendReasonPhrase="false" relaxedPathChars='^[]' relaxedQueryChars='[]' maxThreads="1200" />
This configuration ensures that both ^ and [ ] characters are allowed in the path.
Note that the [ ] characters are preserved in the path/query string by default.
Once you've made the necessary changes, restart Artifactory for the new settings to take effect.
If you encounter similar issues with other special characters in the query string (after the ? in the URL), you can modify the relaxedQueryChars attribute in a similar manner.