Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NATS connection with username / password with URI Escape characters fails #139

Open
sushilrai opened this issue Dec 10, 2023 · 0 comments
Open
Labels
defect Suspected defect such as a bug or regression

Comments

@sushilrai
Copy link

Observed behavior

If username is "nats" and password contains some URI escape characters for example "/iq/Vm/QXzfR8Q==" then connection fails.
Connection required provided using "URL" fails as CGI "unescape" is not user
and when password is passed as options then it fails during the check_password implemented in jruby-9.3.9.0/lib/ruby/stdlib/uri/generic.rb

Only option to make the connection is to change the password to have non-esacape characters or patch the nats code to unescape CGI characters passed in the username / password

Expected behavior

Support for CGI unescape to allow username / password with special characters

Server and client version

nats-pure (2.4.0)

Host environment

SLES

Steps to reproduce

nats_user = CGI.escape(options.NATS_USERNAME)
nats_password = CGI.escape(options.NATS_USER_PASSWORD)
nats_host = options.NATS_SERVER || ENV["NATS_SERVER"] || "nats_server"
nats_port = options.port || ENV["NATS_PORT"] || "4222"

    url = "tls://%s:%s@%s:%s" % [nats_user, nats_password, nats_host, nats_port]
    #url = "tls://%s:%s" % [nats_host, nats_port]
    tls_context = OpenSSL::SSL::SSLContext.new
    tls_context.ssl_version = :TLSv1_2
    tls_context.set_params
    tls_context.cert = OpenSSL::X509::Certificate.new File.open(tls_cert_location)
    tls_context.key = OpenSSL::PKey::RSA.new File.open(tls_cert_key)
    tls_context.ca_file = ca_cert_location

      @client = NATS.connect(
        servers: [url],
        reconnect: false,
        tls: {
          context: tls_context
        }
      )
@sushilrai sushilrai added the defect Suspected defect such as a bug or regression label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

1 participant