GithubHelp home page GithubHelp logo

Comments (12)

maxmoser1 avatar maxmoser1 commented on June 14, 2024 1

This is how the certificate file looks like in notepad++ after enabling "show all characters" - so I would say nothing unusual:

cert-crlf (content is censored as the black block)

from crc.

gbraad avatar gbraad commented on June 14, 2024

Would it be possible to log in to the VM and share the content of /tmp/user-ca-bundle.json ?

from crc.

maxmoser1 avatar maxmoser1 commented on June 14, 2024

Is it possible to submit the file in a private Red Hat Support Ticket?
If not I'll generate a new cert that I will be able to share publicly (even if it is just about the public part).

from crc.

cfergeau avatar cfergeau commented on June 14, 2024

This code

`
// Replace the carriage return ("\n" or "\r\n") with literal `\n` string
re := regexp.MustCompile(`\r?\n`)
p := fmt.Sprintf(proxyCABundleTemplate, re.ReplaceAllString(proxy.ProxyCACert, `\n`), trustedCAName)
replaces \r\n with \n, but according to the error message there are some \r left after doing this.

Could you check your cert file for occurrences of \r, in particular occurrences which are not followed by \n? https://stackoverflow.com/questions/1446370/text-editor-which-shows-r-n has some suggestions to see these special chars on Windows.

from crc.

gbraad avatar gbraad commented on June 14, 2024

replaces \r\n with \n, b

@cfergeau according to the comment it

Replace the carriage return ("\n" or "\r\n") with the string appended with \n

To what I understand, this matches 'once' all the options:

  • optionally match '\r'
  • Exactly once match '\n'

So what if the file contained multiple matches of a newline?

from crc.

cfergeau avatar cfergeau commented on June 14, 2024

The code uses re.ReplaceAllString which should replace all occurrences.

from crc.

maxmoser1 avatar maxmoser1 commented on June 14, 2024

I also copied the user-ca-bundle.json via scp to the Windows host and opened in notepad++.
The highlighted part (yellow) looks strange, no?

CR"LF
user-ca-bundle json 2

from crc.

maxmoser1 avatar maxmoser1 commented on June 14, 2024

This is how the certificate file looks like in notepad++ after enabling "show all characters" - so I would say nothing unusual:

cert-crlf (content is censored as the black block)

I managed to work around the issue by removing line 23 (the last empty line).
This should give you a good hint as to where the root cause of this issue is so it can be fixed for other users.

from crc.

cfergeau avatar cfergeau commented on June 14, 2024

I managed to work around the issue by removing line 23 (the last empty line).

What does the file looks like after removing this 'empty' line? and/or on line 22 disappears?
The on line 4 of user-ca-bundle.json is what is causing the problem. Are there more occurences in line 4 or is this the only one?

I tried to reproduce with data similar to yours ( cacert := "----BEGIN CERTIFICATE----\r\nXXXXV\r\nXXXX3\r\nXXXXF\r\nXXXXM=\r\n----END CERTIFICATE----\r\n") but this behaves as expected - no extra /r.

from crc.

maxmoser1 avatar maxmoser1 commented on June 14, 2024

This is how the certificate file looks like with the "workaround" applied:

  • no empty line 23
  • no CRLF in line 22
fixed

from crc.

maxmoser1 avatar maxmoser1 commented on June 14, 2024

The on line 4 of user-ca-bundle.json is what is causing the problem. Are there more occurences in line 4 or is this the only one?

Did you mean

The "one" line 4 of ...

there?

from crc.

praveenkumar avatar praveenkumar commented on June 14, 2024

I found out the issue and able to reproduce it, looks like our trimTrailingEOL need to be updated for \r\n instead just for \n . I am going to update this function and also try to add test case around it even replacing \r\n => \n should be part of httpproxy package.

package main

import (
	"fmt"
	"strings"
)

func parseProxyCAData() (string, error) {
	rawData := "-----BEGIN CERTIFICATE-----\r\nMIID6zCCAtOgAwIB\r\nKMGinNDOEwKTFXf\r\n-----END CERTIFICATE-----\r\n\r\n"
	return trimTrailingEOL(rawData), nil
}

func trimTrailingEOL(s string) string {
	fmt.Printf("s: %#v", s)
	s1 := strings.TrimRight(s, "\n")
	fmt.Println()
	fmt.Printf("s1: %#v", s1)
	return s1
}

func main() {
	_, err := parseProxyCAData()
	if err != nil {
		fmt.Printf("error: %v", err)
	}
}

Output

$ go run main.go 
s: "-----BEGIN CERTIFICATE-----\r\nMIID6zCCAtOgAwIB\r\nKMGinNDOEwKTFXf\r\n-----END CERTIFICATE-----\r\n\r\n"
s1: "-----BEGIN CERTIFICATE-----\r\nMIID6zCCAtOgAwIB\r\nKMGinNDOEwKTFXf\r\n-----END CERTIFICATE-----\r\n\r" <= here is the extra \r

from crc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.