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

Leaf Node Credentials File regex dies on CRLF file endings #6167

Closed
Madgvox opened this issue Nov 24, 2024 · 1 comment · Fixed by #6175
Closed

Leaf Node Credentials File regex dies on CRLF file endings #6167

Madgvox opened this issue Nov 24, 2024 · 1 comment · Fixed by #6175
Assignees
Labels
defect Suspected defect such as a bug or regression

Comments

@Madgvox
Copy link

Madgvox commented Nov 24, 2024

Observed behavior

When attempting to read a .creds file with CRLF line endings via a leaf node config, nats-server dies with a LeafNode Remote Credentials file "..." malformed error.

Looks like this was an issue in another area of the code years ago (https://github.com/nats-io/jwt/pull/72/files), but this one is due to a different regex that doesn't have that fix:

var credsRe = regexp.MustCompile(`\s*(?:(?:[-]{3,}[^\n]*[-]{3,}\n)(.+)(?:\n\s*[-]{3,}[^\n]*[-]{3,}\n))`)

Expected behavior

The nats-server executable should be able to parse CRLF line endings.

Server and client version

nats-server: v2.10.22

Host environment

Windows 11

Steps to reproduce

  1. Create a *.creds file with CRLF line endings.
  2. Specify that creds file in a leaf.conf file. Mine looked like this:
leafnodes {
  remotes = [
    {
     url: "tls://connect.ngs.global"
     credentials: "..."
    },
  ]
}
  1. Start the server and observe the error: LeafNode Remote Credentials file "..." malformed
@Madgvox Madgvox added the defect Suspected defect such as a bug or regression label Nov 24, 2024
@aricart
Copy link
Member

aricart commented Nov 25, 2024

@Madgvox thank you for the report and the tracking.

aricart added a commit that referenced this issue Nov 25, 2024
…andle CRLFs correctly.

Fix #6167

Signed-off-by: Alberto Ricart <[email protected]>
neilalexander pushed a commit that referenced this issue Nov 26, 2024
…andle CRLFs correctly (#6175)

Leaf node credential parsing was using a regular expression that didn't
handle CRLFs correctly

Fix #6167

Signed-off-by: Your Name <[email protected]>

---------

Signed-off-by: Alberto Ricart <[email protected]>
neilalexander pushed a commit that referenced this issue Nov 26, 2024
…andle CRLFs correctly (#6175)

Leaf node credential parsing was using a regular expression that didn't
handle CRLFs correctly

Fix #6167

Signed-off-by: Your Name <[email protected]>

---------

Signed-off-by: Alberto Ricart <[email protected]>
neilalexander pushed a commit that referenced this issue Nov 26, 2024
…andle CRLFs correctly (#6175)

Leaf node credential parsing was using a regular expression that didn't
handle CRLFs correctly

Fix #6167

Signed-off-by: Your Name <[email protected]>

---------

Signed-off-by: Alberto Ricart <[email protected]>
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
3 participants