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

makeCA() in certs.go saves the wrong ca.key #3

Open
drtimf opened this issue Mar 20, 2023 · 1 comment
Open

makeCA() in certs.go saves the wrong ca.key #3

drtimf opened this issue Mar 20, 2023 · 1 comment

Comments

@drtimf
Copy link

drtimf commented Mar 20, 2023

I think there is a cut-and-paste error here:

caPrivKeyPEM := new(bytes.Buffer)
pem.Encode(caPrivKeyPEM, &pem.Block{
	Type:  "RSA PRIVATE KEY",
	Bytes: x509.MarshalPKCS1PrivateKey(caKey),
})
if err := ioutil.WriteFile(path + "ca.key", caPEM.Bytes(), 0644); err != nil {
	log.Printf("Write the CA certificate file error: %v\n", err)
	return nil, nil, err
}

I suspect the caPrivKeyPEM.Bytes() rather than the caPEM.Bytes() should be written to ca.key.

@nirui
Copy link

nirui commented Sep 13, 2023

I was wondering the same, maybe it's a copy error. Another one is the string "Write the CA certificate file error" in the makeCert function, which should have been something like "unable to write certificate/key file" since the operations there has nothing to do with CA (other than the signing part).

Sadly, though, the author of this repository has passed away back in May due to cardiovascular complications. I'm sure that he would gladly further improve his work if things played out differently for him, but under this reality, I guess for the rest of us who's still trying to setup this damn x509 certificate scheme correctly, we just have to read the code more carefully in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants