Answer the question
In order to leave comments, you need to log in
How to send ssl certificates?
Hello everyone)
I have a couple of questions about ssl certificates, can anyone help me figure it out?
From the previous developer, I got the code where there is a connection to one service. That service is accessed by a curl request sending an ssl certificate. The certificate has expired. I looked at the instructions for connecting to the service. It says that you need to generate a new certificate using OpenSSL and send it to them for signing.
Here is the command openssl req -new -newkey rsa:2048 -nodes -keyout cert.key -sha1 -out cert.csr
But before I had time to send them anything, they sent me a new certificate.
1) How did they generate it without a request? Like an old request? That is, the request has no expiration date?
2) The certificate that they sent me, if you look through a special program, on a macbook it's keychain access, you can see that our develop environment domain is specified as the domain. But requests for this certificate are sent from any other domain. What for then in the certificate in general to specify the domain if it is possible to send requests from any? Or do they somehow set it up when they sign the certificate on their side? I just thought that if the certificate was created for a specific domain (common name is specified), then requests for this certificate will only work from that domain.
3) Among the certificates on this project were two keys. One with
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
Second
-----BEGIN RSA PRIVATE KEY-----
----END RSA PRIVATE KEY-----
I verified that both of these keys belong to the certificate using the commands to calculate the certificate module hash:
openssl x509 -noout -modulus -in <filename>.crt | openssl md5
openssl rsa -noout -modulus -in <filename>.key | openssl md5
It turned out that although these keys look different, they both fit the certificate. Esteemed about a difference of these keys. It turned out that this is one key, but in different formats, the first in the new PKCS8 format, and the second in the old PKCS1 format. The only difference is that in the new format its type is encrypted in the key, if I understand correctly.
3.1 I tried to send requests with both keys, but it came out only with a key in the new PKCS8 format, why are they the same?
3.2 Sending a request is only possible if the key is specified in the certificate file itself, that is, I combined them into one file and then the request worked. Why doesn't it work individually?
3.3 Do I understand correctly that the PKCS1 and PKCS8 key formats have nothing to do with the pem format? That is, a pem file can be in PKCS8 format, like some kind of subformat? Or are all of these generally different formats, and if the file is in PKCS8 format, does this mean that it is not in pem format?
3.4 Are the PKCS1 and PKCS8 formats just for keys or for a certificate too?
3.5 If these are the formats for the certificate, then it may be that the old key, although it belongs to the certificate, but requests are not sent with it because it is in the PKCS1 format, and the certificate itself is valid in the PKCS8 format? That is, the certificate and key must be in the same format?
3.6 Is it possible to somehow define key and certificate formats? I understand that the file extension does not mean anything at all? That is, there can be a certificate with the .pem extension, but the key format can be PKCS8?
I would be grateful if someone could answer at least some of these questions.
Answer the question
In order to leave comments, you need to log in
That is, the request has no expiration date?
But requests for this certificate are sent from any other domain. What for then in the certificate in general to specify the domain if it is possible to send requests from any?
Sending a request is only possible if the key is specified in the certificate file itself, that is, I combined them into one file and then the request worked. Why doesn't it work individually?
Do I understand correctly that the PKCS1 and PKCS8 key format have nothing to do with the pem format?
The universal rule is not to use in production any certificates whose private key was not generated by you and which was sent somewhere. If you need to update / re-release - generate the key yourself, send the CSR from it where necessary, and then let them do what they want.
In general, if we are talking about public domain names (under your control), then all dances with certification centers are solved by setting Let`s Encrypt once.
3.4 Are the PKCS1 and PKCS8 formats just for keys or for a certificate too?
3.2 Sending a request is only possible if the key is specified in the certificate file itself, that is, I combined them into one file and then the request worked. Why doesn't it work individually?
But before I had time to send them anything, they sent me a new certificate. How did they generate it without a request? Like an old request? That is, the request has no expiration date?
But requests for this certificate are sent from any other domain. What for then in the certificate in general to specify the domain if it is possible to send requests from any?
1) To generate a certificate, it is not necessary to make a request, especially since you have a certificate for client authorization. The difference is in the private key, if you send a request, then only you will have the private key, if they sent you a certificate, then this is a new pair of certificate + key. Accordingly - not only you have the key)
2) This is a client certificate. It checks other fields, it is not tied to a domain. Required to identify the client on the server (analogue login + password, but cooler in terms of security)
3) Yes, these are just different recording formats. Different applications require different formats.
3.1) Different applications require different formats.
3.2) Different applications require different formats.
3.3) pem - determines that this file stores a certificate. Implies, but does not define, the format of the certificate entry in it.
3.4) Public-Key Cryptography Standards - the answer is in the title.
3.5) The old key will not work for you, because. they generated a new key and signed a new certificate with them and sent it to you.
3.6) Yes, the file extension may not match the content.
It is possible by enumeration
openssl pkcs12 -text -in certificate.pfx
openssl x509 -text -in certificate.pem
openssl pkcs8 -text -in certificate.cer
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question