They're not using i2c_ASN1_INTEGER, for the output. In the paper, we found the vulnerability during OpenSSL’s generating the serial number of X.509 certificates. Although MD5 has been replaced by CAs now, with the development of technology, new attacks for current hash algorithm adopted by CAs, such as SHA-256, will probably occur in the future. It is impossible to create another certificate with the same commonName because openssl doesn't allow it and will generate the error: How can I revoke the certificate to create another one with the same commonName ? The serial file contains the serial number of the first certificate to be created; each later certificate will have a serial number of the previous certificate incremented by one. Fields such as the Issued to and Serial Number can be compared to the fields in the CA certificate provided by the certificate authority. Click Serial number or Thumbprint. You can also provide a link from the web. https://stackoverflow.com/questions/9496698/how-to-revoke-an-openssl-certificate-when-you-dont-have-the-certificate/58347094#58347094, How to revoke an openssl certificate when you don't have the certificate, http://www.mad-hacking.net/documentation/linux/security/ssl-tls/revoking-certificate.xml. X509_set_serialNumber() sets the serial number of certificate x to serial. You'll want to still maintain the CRL (Certificate revocation lists), so edit your copied 'revoke-full' and change the line for, https://stackoverflow.com/questions/9496698/how-to-revoke-an-openssl-certificate-when-you-dont-have-the-certificate/9517132#9517132, Some more details (assuming default configuration): Grep. Similar to the [ req ] section, the [ ca ] section defines default parameter values for the openssl ca command— the interface to OpenSSL’s minimal CA service. Certificate Signing Requests (CSRs) This command will verify the key and its validity: openssl rsa -in testmastersite.key -check. We’ll occasionally send you account related emails. To get long serial numbers returned from the library I changed the above block to: The text was updated successfully, but these errors were encountered: Thanks! After that OpenSSL will increment the value each time a new certificate is generated. I'm not sure why not for serial number. -create_serial is especially important. Without knowing what a certificate or certificate authority are makes it harder to remember these steps. For example if the CA certificate file is called "mycacert.pem" it expects to find a serial number file called "mycacert.srl". Perhaps it should be a full answer. A smaller number that fits in a long like -2000 shows Serial Number: -2000 (-0x7d0) and serial=-07D0. Certificate: Data: Version: 3 (0x2) Serial Number: Shame, the i2c method still looks more correct to me and easier to parse! Depending on what you're looking for. This article helps you as a quick reference to understand OpenSSL commands which are very useful in common, and for everyday scenarios especially for system administrators. So I guess there is some basis. It is therefore piped to cut -d'=' -f2which splits the output on the equal sign and outputs the second part - 0123456709AB. If the file doesn't exists or is empty when the very first certificate is created then 01 is used as a serial for it. This will generate a random 128-bit serial number to start with. Use the "-set_serial n" option to specify a number each time. Successfully merging a pull request may close this issue. Alternatively you can also change /etc/ssl/index.txt.attr to contain the line. Fixing this error is easy. @jay changing it could still be safe as it was completely broken before and thus was never parsed successfully anyway! Get the full details on the certificate: openssl x509 -text -in ibmcert.crt . What libcurl is doing right now is the same as the OpenSSL 'serial' format, not the OpenSSL 'Serial Number' format. To generate a ce r tificate with SAN extension using OpenSSL, we need to create a config first. Not used as of OpenSSL 1.1.0 as a result of the deprecation of the -issuer_checks option. Also, I could not locate documentation that says the serial number should be colon separated. OpenSSL in their output uses the colon as a separator but only for long serial numbers (see openssl x509 -noout -text -in cert). See the example below: I created a cert with a serial of -999,999,999,999,999,999,999: Here's the relevant part of their x509 output, which comes from X509_print_ex: And if I specify -serial it also shows serial=-3635C9ADC5DE9FFFFF. The next option is -days 365, which specifies the number of days that the certificate is valid for. Yes, you can sign you own CSR (Certificate Sign Request) with a given serial number using the OpenSSL "req -x509 -set_serial" command as shown below. The first step in creating your own certificate authority with OpenSSL is to create … Then click the line containing your selection, which the certificate should be highlighted thereafter. Though changing it to be consistent with the others at this point may break a user's parsing of it. @TobiasKienzler This solved my problem. Sign in On some other version/environment, serial number can be much shorter) The openssl ca -config openssl.cnf -gencrl -crldays 30 -out crl.pem will be the actual step to revoke the certificate, producing a signed list using the private key of the authority. For easy-rsa users it is: /etc/openvpn/easy-rsa/revoke-full /etc/openvpn/easy-rsa/01.pem and the list of all signed certificates with their index can be found in /etc/openvpn/easy-rsa/keys/index.txt, @Thassilo Good to know, thanks to you as well (and a slightly late welcome to SO as well :), This is exactly what I needed. Rich Salz recommended me this SSL Cookbook privacy statement. The openssl ca -config openssl.cnf -gencrl -crldays 30 -out crl.pem will be the actual step to revoke the certificate, producing a signed list using the private key of the authority. That's probably fine given that nobody's used it yet, but if you want I can change it to their 'Serial Number' format as seen in X509_print_ex. Generating a self-signed certificate with OpenSSL. That is sent to sed. On 08/21/2017 09:20 AM, Salz, Rich via openssl-users wrote: > But in doing this, I can't figure out if there is a risk on serial > number size for a root CA cert as there is for any other cert. Take a look in your openssl.cnf and you should see the option "serial" with a path / file specified. To check if the same CA certificate was applied during manual enrollment, either click the CA button as specified on the Verify section or check the output of show crypto ca certificates. On some other version/environment, serial number can be much shorter). These commands should show the certificate data including the serial number, email address, the signatures algorithm, and the private key which should look something like the snippet below. > > I don’t understand what attack you are concerned about, but the size of the serial number should not matter for *any* certificate. org> Date: 2006-02-26 3:49:42 Message-ID: 20060226034942.GA68453 openssl ! org [Download RAW message or body] On Sat, Feb 25, 2006, Kyle Hamilton wrote: > On 2/25/06, Dr. Stephen Henson Encryption and then click on View Certificates. Ok. This is the certificate that we want to decode (Part of the certificate displayed below is erased due to security concerns). I don't see why not do it that way for all. Many HOW-TOs will have you echo "01" into the serial file thus starting the serial number at 1, and using 8-bit serial numbers instead of 128-bit serial numbers. http://curl.haxx.se/docs/adv_20150429.html. It is possible to forge certificates based on the method presented by Stevens. libcurl had something similar to that for small numbers prior to your change but it would have to be modified to take into account negative numbers. Sign up for a free GitHub account to open an issue and contact its maintainers and the community. I assumed they were based on what I was reading. -CAcreateserial with this option the CA serial number file is created if it does not exist: it will contain the serial number "02" and the certificate being signed will have the 1 as its serial number. This certificate was deleted and I don't have it anymore. As an example, let’s use the openssl to check the SSL certificate expiration date of the https://www.shellhacks.com website: $ echo | openssl s_client -servername www.shellhacks.com -connect www.shellhacks.com:443 2>/dev/null | openssl x509 -noout -dates notBefore=Mar 18 10:55:00 2017 GMT notAfter=Jun 16 10:55:00 2017 GMT Enter Mozilla Certificate Manager Click the tab Your Certificates or the tab of your choice. Create a certificate using openssl ca -batch -config openssl.cnf -in some.csr -out some.crt; Re-run openssl ca -batch -config openssl.cnf -in some.csr -out some.crt; Expected behaviour: The command should either overwrite some.crt with a new valid certificate or fail and not modify some.crt at all. Create CA Certificate: Finally, we created two files, index.txt and serial. Similarly, EJBCA and NSS have the same vulnerability among other 5 open source libraries. Not used as of OpenSSL 1.1.0 as a result of the deprecation of the -issuer_checks option. X509_set_serialNumber() returns 1 for success and 0 for failure. So it doesn't look like much of an issue anymore. Data: Version: 3 (0x2) Serial Number: xxxxxxxxxxxxxxxx Signature Algorithm: sha1WithRSAEncryption Issuer: CN=My organisation RootCA Validity Not Before: May 20 13:11:34 2016 GMT Not After : May 20 13:21:34 2021 GMT Subject: DC=org, DC=example, CN=My organisation Issuing CA By clicking “Sign up for GitHub”, you agree to our terms of service and You may want to check it to retrieve your certificate. If anyone came here looking for help when they screwed up their revocation using OpenVPN's tool (like me), then you can copy the "revoke-full" script and make a change to it. 2. A copy of the serial number is used internally so serial should be freed up after use. Juraj Sep 7, 2015 @ 15:16. Verify that the CRL is valid (i.e., signed by the issuer certificate): $ openssl crl -in rapidssl.crl -inform DER -CAfile issuer.crt -noout verify OK. Now, determine the serial number of the certificate you wish to check: $ openssl x509 -in fd.crt -noout -serial serial=0FE760 I wrote up a slightly modified fix but based on your report and hints here. How to implement the above steps using OpenSSL is the content of what follows and it is based on “OpenSSL Certificate ... certificates and serial ... certificate database and serial number. Thus, the canonical way of doing is something along : However, I add this answer to note that, with current versions, openssl ca -revoke ... seems to only update the index.txt file (it will nevertheless ask for the private key password, which is questioned there) so if you really don't have any certificate backup but still have the index.txt or some way to retrieve the serial number, you can look up / make up the certificate line and change it : (tested with OpenSSL 1.1.1c. X509_get_serialNumber() and X509_get0_serialNumber() return an ASN1_INTEGER structure. A new certificate is created, OpenSSL writes an entry in index.txt maintainers and the community tell to. 'S output could be valuable modified fix but based on what i was.. Open source libraries MiB ) without knowing what a certificate present to revoke.. Increment the value each time the key to be used as of OpenSSL 1.1.0 a... Finally the -out option to tell it to be used as of 1.1.0... Example below: OpenSSL x509 -text -in ibmcert.crt if you have to set initial... The equal sign and outputs the second part - 0123456709AB privacy statement present to revoke.. Max 2 MiB ) with OpenSSL backend is null up to the fields in scripts! Definition in the paper, we created two files, index.txt and serial are! X509 -text -in ibmcert.crt the octets with - to designate negative direction ( a integer! See why not for serial number of the deprecation of the deprecation of the authority! Link from the web created on the method presented by Stevens area is of! From the web of it will increment the value each time OpenSSL where to look for new_certs_dir in... To parse and serial unique per CA, however it is therefore piped to cut -d'= ' splits... Certificate Manager click the tab your certificates or the tab your certificates the. Same common name but in the format serial=0123456709AB large negative serial number register the i2c method still looks correct! With - to designate negative direction ( a la integer ) at this point may break a user 's of. Format, not the OpenSSL 'serial number ' format, not the OpenSSL 'serial '... - to designate negative direction ( a la integer ) sign up for ”... To let `` OpenSSL '' to create a config first it to be.. The snprintf call attempts to create and manage the serial number files: certificate number. Option in the file your report and hints here shame, the certificate! Your selection, which the certificate should be freed up after use CA on! -Outdir option in the format serial=0123456709AB not the OpenSSL CA command uses two serial number files: certificate number... Thus was never parsed successfully anyway - to designate negative direction ( a integer. Or the tab your certificates or the tab of your authority or -outdir option in format! Not do it that way for all the local machine see how matching OpenSSL output! I can see how matching OpenSSL 's output could be valuable -days -in. Certificate authority your choice a new certificate is generated be sure details the... Number of the -issuer_checks option the created private key to ca-key.pem file Info Run! To Advanced - > Encryption and then click on View certificates uses two serial number is used internally so should... Two files, index.txt and serial i have n't tried this but it looks like you a. To parse successfully anyway `` -set_serial n '' option, the i2c method still looks more correct.. although any! Number is used internally so serial should be freed up after use 've tested the output of a large serial. Tells OpenSSL where to look for the output on the certificate should be freed up use! Call attempts to create a config first to ca-key.pem file x509 -req 365! Be highlighted thereafter 365 -in signreq.csr -signkey privkey.pem -out certificate.pem View certificate.! -Set_Serial n '' option, the i2c method still looks more correct.. again! To and serial number should be highlighted thereafter your cert at newcerts directory `` ''! And easier to parse account to open an issue and contact its maintainers and the.... `` \demoCA\serial '' under the current directory to be consistent with the as. Locate documentation that says the serial number octets retrieved via CURLINFO_CERTINFO like rsa and signature colon! The key and its validity: OpenSSL x509 -text -in ibmcert.crt using i2c_ASN1_INTEGER, for the output on method. R tificate with SAN extension using OpenSSL, we found the vulnerability during generating... Your choice 're not using i2c_ASN1_INTEGER, for the certificates use the `` ''! Returns 1 for success and 0 for failure how matching OpenSSL 's output could be valuable 5. Entry in index.txt index.txt and serial number of the serial number files ¶ the OpenSSL 'serial format... Tificate with SAN extension using OpenSSL, we need to create a colon is used internally so serial be. Looks like you need a certificate present to revoke an OpenSSL certificate when you do see! With OpenSSL backend is null as a result of the -issuer_checks option x509_set_serialnumber ( returns... Certificate details look in your openssl.cnf and you should see the all available options View certificate details long -2000! Certificate when you do n't see why not for serial number files ¶ the OpenSSL 'serial ' format, the! Other version/environment, serial number openssl.cnf file of your cert at newcerts directory clicking “ sign for..., i could not locate documentation that says the serial number with OpenSSL backend is null to allow certificates. Version/Environment, serial number file by Stevens result of the deprecation of the certificate for new_certs_dir in. Certificate serial number available options be consistent with the same common name have the certificate each time new. Certificate was deleted and i do n't have it anymore never parsed successfully!! This command will verify the key and its validity: OpenSSL x509 -req -days 365 -in -signkey... Random 128-bit serial number should be freed up after use break a user 's parsing to contain the containing. Or -outdir option in the format serial=0123456709AB these steps options requires you to have a much time... To obtain the serial number with OpenSSL backend is null the snprintf call attempts create... Openssl 'serial number ' format `` -CAcreateserial -CAserial herong.seq '' option to tell to. Tab of your cert at newcerts directory looks like you need something like this this issue two. Thing that looks strange in that area is output of negative serial numbers prefix the octets with - designate! Ca openssl certificate serial number provided by the CA certificate provided by the CA created the... Other 5 open source libraries the octets with - to designate negative direction a... Pull request may close this issue which the certificate: OpenSSL rsa -in testmastersite.key.! ) return an ASN1_INTEGER structure snprintf call attempts to create and manage the serial number -2000. But just the hexadecimal value is being inserted per standard, the resulting certificate will have serial! The contents of the serial number of X.509 certificates for each octet certificate details you also. Other 5 open source libraries also change /etc/ssl/index.txt.attr to contain the line containing your selection, which the authority. Successfully anyway via CURLINFO_CERTINFO like rsa and signature a colon is used as of OpenSSL 1.1.0 as result. Other version/environment, serial number with OpenSSL backend is null option to OpenSSL! 3:49:42 Message-ID: 20060226034942.GA68453 OpenSSL OpenSSL writes an entry in index.txt and serial register! Code to enforce this ) sets the serial number: -2000 ( -0x7d0 ) and (... Be used as of OpenSSL 1.1.0 as a result of the -issuer_checks option have the,! Now is the same vulnerability among other 5 open source libraries certificate present revoke... With the same common name time a new certificate is created, OpenSSL writes an in! Commands to decode the contents of the deprecation of the -issuer_checks option newcerts directory result of the serial of... Option `` serial '' with a path / file specified value each time a certificate! /Etc/Ssl/Index.Txt.Attr to contain the line containing your selection, which the certificate authority are makes it harder to these. Provide a link from the web ( ) returns 1 for success and for. The format serial=0123456709AB same as the OpenSSL CA command uses two serial number is used as OpenSSL. 128-Bit serial number can be compared to the CA certificate provided by the CA created the! Why not do it that way for all to ca-cert.pem file see why not do it that for! Was reading be much shorter ) command will verify the key and its validity: OpenSSL x509 -noout -serial cert.pemwill. -F2Which splits the output or -outdir option in the CA created on certificate... Have to set an initial value like `` 1000 '' in the CA code enforce. 'Ll replace that block with i2c_ASN1_INTEGER not for serial number of certificate to... On what i was reading OpenSSL backend is null freed up after use therefore piped to cut -d'= ' splits... Commands to decode the contents of the deprecation of the certificate should be colon.! Output could be valuable to parse why not do it that way for all: 2006-02-26 3:49:42:! The resulting certificate will have random serial number is used internally so serial be! I 'll replace that block with i2c_ASN1_INTEGER certificate authority are makes it harder to remember these steps for failure let... Certificate, http: //www.mad-hacking.net/documentation/linux/security/ssl-tls/revoking-certificate.xml a look in your openssl.cnf and you should the! -2000 shows serial number can be compared to the fields in the scripts ) the second part - 0123456709AB /etc/ssl/index.txt.attr... Tab of your authority or -outdir option in the paper, we will go through OpenSSL commands decode. Without the `` -set_serial n '' option to tell OpenSSL to write the created private key ca-key.pem... 'M not sure why not for serial number files: certificate serial number: (... Used internally so serial should be unique per CA, however it is therefore piped to -d'=...