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

Private key doesn't contains PKI error #42

Open
ZenkieBear opened this issue Apr 29, 2024 · 2 comments
Open

Private key doesn't contains PKI error #42

ZenkieBear opened this issue Apr 29, 2024 · 2 comments

Comments

@ZenkieBear
Copy link
Contributor

image

When I use xca to open the key.pem file, some error occurs.
When I use curl to access a mTLS connection, the private key cannot be read.
image

@ZenkieBear
Copy link
Contributor Author

If you signing a CA and Certificates follow steps below, it works right and private key could be read through xca
This required openssl is installed on your PC.

Create Root CA

# Private key
openssl genrsa -out root.key 2048

# Self signed Certificate Authority
openssl req -new -x509 -days 365 -key root.key -out root.crt

Create Server Certificate

# Private key
openssl genrsa -out server.key 2048

# CSR file
openssl req -new -out server.csr -key server.key

# Signing Certificate
openssl x509 -req -in server.csr -out server.crt -CA root.crt -CAkey root.key -CAcreateserial -days 365 -extfile ../server.conf

@ZenkieBear
Copy link
Contributor Author

Found the reason:
When GOCA encoding the rsa private key and public key to PEM format, it uses "PRIVATE KEY" and "PUBLIC KEY", but the standard format should be "RSA PRIVATE KEY" or "RSA PUBLIC KEY", GOCA lost the RSA prefix.

That's why CURL and xca cannot read the PEM file, they verifies the PEM file first.

I will create a PR soon.

ZenkieBear added a commit to ZenkieBear/goca that referenced this issue May 10, 2024
The standard PEM key file should named "RSA PRIVATE KEY" or "RSA PUBLIC KEY".

fixed: kairoaraujo#42
ZenkieBear added a commit to ZenkieBear/goca that referenced this issue May 10, 2024
The standard PEM key file should named "RSA PRIVATE KEY" or "RSA PUBLIC KEY".

fixed: kairoaraujo#42
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

1 participant