RE: Certificate extensions
Peter, > -Original Message- > From: Peter Sylvester > > On 09/18/2013 09:53 AM, Eisenacher, Patrick wrote: > >> -Please also note that adding extensions to a certificate request > usually doesn't make any sense, as those get added to the certificate solely > by the certificate issuer's grace. > >> > >> > hi, > > I seem to disagree, well, "usually" saves you :-) > > Setting your email address or a server name into the subjectaltname, how do > you do this otherwise? > setting commonname for the server, ok, setting an email attribute that will > them > be copied by the CA (and the email removed because it is depracated)? > > Setting ALL extensions makes a lot of sense, IMO a CA should not add and > modify thngs, a CA > should *validate* them. The requester indicates what should be in the cert. > > The current practice by some registrars to add example.org as another name > when > you have ordered www.example.com etc may be nice for some people, but > annoying > for others, at best a surprise when policy and practice documents do not > even mention > these behaviours. you give valid exceptions, that's why I said usually. Those exceptions all serve to identiy the subject. It doesn't matter how these infos reach the CA, be it in-band or out-of-band. And it shouldn't matter how the request encodes that information in case the info is given in-band. The CA issues certificates conforming to a specific certificate profile. If the CA issues different types of certificates, it has a certificate profile for each type. The requestor can only choose between the types, ie. client or server cert, but not choose the structure of the certificate. Since a certificate is complex, PKI-knowledge is rare and the CA is liable for it, I don't think that letting your customers determine extensions or their criticality is a good idea. Furthermore, the CA's QA wouldn't be able to validate that their system works as expected and issues sound certificates that conform to PKIX or some other profile. Patrick Eisenacher
Re: Certificate extensions
On 09/18/2013 09:53 AM, Eisenacher, Patrick wrote: -Please also note that adding extensions to a certificate request usually doesn't make any sense, as those get added to the certificate solely by the certificate issuer's grace. hi, I seem to disagree, well, "usually" saves you :-) Setting your email address or a server name into the subjectaltname, how do you do this otherwise? setting commonname for the server, ok, setting an email attribute that will them be copied by the CA (and the email removed because it is depracated)? Setting ALL extensions makes a lot of sense, IMO a CA should not add and modify thngs, a CA should *validate* them. The requester indicates what should be in the cert. The current practice by some registrars to add example.org as another name when you have ordered www.example.com etc may be nice for some people, but annoying for others, at best a surprise when policy and practice documents do not even mention these behaviours. Peter Sylvester __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
RE: Certificate extensions
> -Original Message- > From: radiatejava > > I have some doubts on how to use certificate extensions. I have this > openssl.cnf file: [snip] > Using this I want to generate a certificate for client > (extendedkeyusage=clientAuth) and one for server(extended key usage = > serverAuth). > > However, when I run a command like this, it does not seem to be > considering the [client_ext] section but only what is under > req_extensions. Can someone explain ? > > openssl req -new -newkey rsa:1024 -keyout clientcomp.key -nodes -out > clientcomp.csr -extensions client_ext -config ./openssl.cnf The req command generates a certificate request. As such it only picks up the corresponding request settings from your config file. If you want to generate a certificate you'll have to use the x509 or ca command. Please also note that adding extensions to a certificate request usually doesn't make any sense, as those get added to the certificate solely by the certificate issuer's grace. HTH, Patrick Eisenacher
Certificate extensions
I have some doubts on how to use certificate extensions. I have this openssl.cnf file: //cat openssl.cnf [v3_ca] basicConstraints = critical,CA:true keyUsage = digitalSignature, cRLSign, keyCertSign [ client_ext ] basicConstraints = CA:false keyUsage = critical,digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment nsCertType = client extendedKeyUsage = clientAuth nsComment = "OpenSSL-generated client authentication certificate" subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always, issuer:always [req] distinguished_name = req_distinguished_name req_extensions = v3_req [ req_distinguished_name ] countryName = Country Name (2 letter code) countryName_min = 2 countryName_max = 2 stateOrProvinceName = State or Province Name (full name) localityName= Locality Name (eg, city) 0.organizationName = Organization Name (eg, company) organizationalUnitName = Organizational Unit Name (eg, section) commonName = Common Name (eg, YOUR name) commonName_max = 64 [ v3_req ] # Extensions to add to a certificate request basicConstraints = CA:FALSE keyUsage = critical,digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment extendedKeyUsage = serverAuth Using this I want to generate a certificate for client (extendedkeyusage=clientAuth) and one for server(extended key usage = serverAuth). However, when I run a command like this, it does not seem to be considering the [client_ext] section but only what is under req_extensions. Can someone explain ? openssl req -new -newkey rsa:1024 -keyout clientcomp.key -nodes -out clientcomp.csr -extensions client_ext -config ./openssl.cnf __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Re: [openssl-users] Re: specifying certificate extensions on command line
No. You can generate your conf file based on other elements, if you need something more flexible. Le 07/12/2011 13:06, sandeep kiran p a écrit : Anyone? can I do this without the conf file? Thanks Sandeep On Thu, Dec 1, 2011 at 7:36 PM, sandeep kiran p mailto:sandeepkir...@gmail.com>> wrote: Hi, Is there any way to specify the certificate extensions (when using "req" and "ca" tools) directly on the command line rather than using the -extensions argument? I am looking for a way where I can avoid using the config file with the "req" and "ca" commands. Thanks, Sandeep -- Erwann ABALEA - pyropyge: qui a le feu aux fesses
Re: specifying certificate extensions on command line
Anyone? can I do this without the conf file? Thanks Sandeep On Thu, Dec 1, 2011 at 7:36 PM, sandeep kiran p wrote: > Hi, > > Is there any way to specify the certificate extensions (when using "req" > and "ca" tools) directly on the command line rather than using the > -extensions argument? I am looking for a way where I can avoid using the > config file with the "req" and "ca" commands. > > Thanks, > Sandeep >
specifying certificate extensions on command line
Hi, Is there any way to specify the certificate extensions (when using "req" and "ca" tools) directly on the command line rather than using the -extensions argument? I am looking for a way where I can avoid using the config file with the "req" and "ca" commands. Thanks, Sandeep
AW: Accessing unknown certificate extensions by OID
Alright, I got it. After inserting the structs etc. in order to hop through the extension, I got down to the ASN1_OBJECT representing the professionOID. OBJ_obj2txt(buf,buflen,obj,1) gives the OID I was looking for (first approach was to create an object with that OID and use obj_cmp, which also works as expected) and I can work with that. Mit freundlichen Grüßen / Kind regards Natanael Mignon Von: Natanael Mignon - michael-wessel.de Gesendet: Freitag, 21. August 2009 14:00 An: openssl-users@openssl.org Betreff: AW: Accessing unknown certificate extensions by OID Hello, ok, what I did so far is get the extension by OID. At least I know by now, whether the extension is present or not: [...] X509 *client_cert = X509_STORE_CTX_get_current_cert(ctx); const char *admoid = "1.3.36.8.3.3"; ASN1_OBJECT *admobj = NULL; X509_EXTENSION *admext = NULL; int extpos; admobj = OBJ_txt2obj(admoid, 0); if (admobj) { extpos = X509_get_ext_by_OBJ(client_cert, admobj,-1); if (extpos) admext = X509_get_ext(client_cert, extpos); if (!admext) { ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, conn, "MWDE/nm: Extension '%s' (admission) not found in cert!", admoid); ok = FALSE; [...] Testing is positive: The extension is found by mod_ssl. But now I need to read and compare the field professionOID (see specs in my initial post). So welcome to asn1 parsing, I guess (because I'm not really familiar with that, I can only guess)... Any help welcome, as usual. :) Mit freundlichen Grüßen / Kind regards Natanael Mignon Von: Natanael Mignon - michael-wessel.de Gesendet: Dienstag, 18. August 2009 16:13 An: openssl-users@openssl.org Betreff: Accessing unknown certificate extensions by OID Dear list, another trial. ;) We need to validate the existence and value of an X.509 extension in a client certificate from within Apache/mod_ssl. The extension "Admission" is described by ISIS-MTT and has OID 1.3.36.8.3.3: AdmissionSyntax ::= SEQUENCE { admissionAuthority GeneralName OPTIONAL, contentsOfAdmissions SEQUENCE OF Admissions } Admissions ::= SEQUENCE { admissionAuthority [0] EXPLICIT GeneralName OPTIONAL, namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL, professionInfos SEQUENCE OF ProfessionInfo } NamingAuthority ::= SEQUENCE { namingAuthorityId OBJECT IDENTIFIER OPTIONAL, namingAuthorityUrl IA5String OPTIONAL, namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL} ProfessionInfo ::= SEQUENCE { namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, addProfessionInfo OCTET STRING OPTIONAL } This does not exactly match what I found here: http://vijairaj.blogspot.com/2009/01/parsing-and-using-custom-extension-in.html, but is taken from the exact specifications we need to comply to. This extension is not known to our OpenSSL version (0.9.8d) and I don't think later versions do know it?! Furthermore, the suggested code at the abovementioned article does not really fit into mod_ssl and I am hesitating to customize OpenSSL itself as well now. It should be possible to read and parse the extension by using ASN1 functions without defining the whole extension for OpenSSL, as it can be displayed with it's OID and raw data by "openssl asn1parse -in ", I think? What I am looking for is a feasible approach to doing so from within mod_ssl. Any help appreciated! In other news: what I achieved already is validating the certificate's signing algorithm and keylength, it's ExtendedKeyUsage data, the signing algorithm and the producedAt date of the OCSP response from within mod_ssl - if anybody is interested... I also 'fixed' the receipt of the actual OCSP response, which failed, if their was an empty line read at the beginning of the response, maybe due to a lag in traffic... (not valid code style according to Apache/httpd, I guess :( ). Mit freundlichen Grüßen / Kind regards Natanael Mignon IT - beraten | planen | umsetzen | betreiben __ michael-wessel.de Informationstechnologie GmbH Krausenstraße 50 30171 Hannover Germany fon (+49) 511 260 911-0 (DW -13) fax (+49) 511 318 039-9 eMailn...@michael-wessel.de web www.michael-wessel.de Geschäftsführer: Michael Wessel Dipl. Phys. Amtsgericht Hannover HR B 59031 Alle Produktnamen und Firmennamen sind ggfs. eingetragene Warenzeichen und/oder Markennamen der jeweiligen Hersteller. Angebote freibleibend, Irrtümer und Druckfehler vorbehalten. Lieferung vorbehaltlich ausreichender Selbstbelieferung. © 2009 michael-wessel.de _
AW: Accessing unknown certificate extensions by OID
Hi and thanks for your continued help! Meanwhile I did indeed define the syntax of the extension and get my way through to the leaf being an ASN1_OBJECT representing the professionOID. Now my lack of knowledge strikes back: I want to check, whether a professionOID of "1.2.276.0.76.4.88" is included in the extension. What I get from i2d_ASN1_OBJECT(profoid, NULL) is plain and simple "9". I still fail to find the method that will present this notation of an OID... Mit freundlichen Grüßen / Kind regards Natanael Mignon Von: owner-openssl-us...@openssl.org [owner-openssl-us...@openssl.org] im Auftrag von Dr. Stephen Henson [st...@openssl.org] Gesendet: Samstag, 22. August 2009 13:50 An: openssl-users@openssl.org Betreff: Re: Accessing unknown certificate extensions by OID Yes you can call X509_EXTENSION_get_data() to get the encoded extension as an ASN1_OCTET_STRING structure. From that ASN1_STRING_length() and ASN1_STRING_data() will get you the data itself. Then it is ASN1 parsing time... there are numerous examples in the OpenSSL code itself, see crypto/cms/cms_asn1.c for a more recent one. Once you have an appropriate ASN1 module you can use d2i_foo() (or whatever you call it) to decode the data you extracted above. Steve. __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Re: Accessing unknown certificate extensions by OID
On Fri, Aug 21, 2009, Natanael Mignon - michael-wessel.de wrote: > Hello, > > ok, what I did so far is get the extension by OID. At least I know by now, > whether the extension is present or not: > > [...] > X509 *client_cert = X509_STORE_CTX_get_current_cert(ctx); > const char *admoid = "1.3.36.8.3.3"; > ASN1_OBJECT *admobj = NULL; > X509_EXTENSION *admext = NULL; > int extpos; > > admobj = OBJ_txt2obj(admoid, 0); > if (admobj) { > extpos = X509_get_ext_by_OBJ(client_cert, admobj,-1); > if (extpos) > admext = X509_get_ext(client_cert, extpos); > if (!admext) { > ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, conn, > "MWDE/nm: Extension '%s' (admission) not found in cert!", > admoid); > ok = FALSE; > [...] > > Testing is positive: The extension is found by mod_ssl. But now I need to > read and compare the field professionOID (see specs in my initial post). So > welcome to asn1 parsing, I guess (because I'm not really familiar with that, > I can only guess)... > > Any help welcome, as usual. :) > Yes you can call X509_EXTENSION_get_data() to get the encoded extension as an ASN1_OCTET_STRING structure. From that ASN1_STRING_length() and ASN1_STRING_data() will get you the data itself. Then it is ASN1 parsing time... there are numerous examples in the OpenSSL code itself, see crypto/cms/cms_asn1.c for a more recent one. Once you have an appropriate ASN1 module you can use d2i_foo() (or whatever you call it) to decode the data you extracted above. Steve. -- Dr Stephen N. Henson. OpenSSL project core developer. Commercial tech support now available see: http://www.openssl.org __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
AW: Accessing unknown certificate extensions by OID
Hello, ok, what I did so far is get the extension by OID. At least I know by now, whether the extension is present or not: [...] X509 *client_cert = X509_STORE_CTX_get_current_cert(ctx); const char *admoid = "1.3.36.8.3.3"; ASN1_OBJECT *admobj = NULL; X509_EXTENSION *admext = NULL; int extpos; admobj = OBJ_txt2obj(admoid, 0); if (admobj) { extpos = X509_get_ext_by_OBJ(client_cert, admobj,-1); if (extpos) admext = X509_get_ext(client_cert, extpos); if (!admext) { ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, conn, "MWDE/nm: Extension '%s' (admission) not found in cert!", admoid); ok = FALSE; [...] Testing is positive: The extension is found by mod_ssl. But now I need to read and compare the field professionOID (see specs in my initial post). So welcome to asn1 parsing, I guess (because I'm not really familiar with that, I can only guess)... Any help welcome, as usual. :) Mit freundlichen Grüßen / Kind regards Natanael Mignon Von: Natanael Mignon - michael-wessel.de Gesendet: Dienstag, 18. August 2009 16:13 An: openssl-users@openssl.org Betreff: Accessing unknown certificate extensions by OID Dear list, another trial. ;) We need to validate the existence and value of an X.509 extension in a client certificate from within Apache/mod_ssl. The extension "Admission" is described by ISIS-MTT and has OID 1.3.36.8.3.3: AdmissionSyntax ::= SEQUENCE { admissionAuthority GeneralName OPTIONAL, contentsOfAdmissions SEQUENCE OF Admissions } Admissions ::= SEQUENCE { admissionAuthority [0] EXPLICIT GeneralName OPTIONAL, namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL, professionInfos SEQUENCE OF ProfessionInfo } NamingAuthority ::= SEQUENCE { namingAuthorityId OBJECT IDENTIFIER OPTIONAL, namingAuthorityUrl IA5String OPTIONAL, namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL} ProfessionInfo ::= SEQUENCE { namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, addProfessionInfo OCTET STRING OPTIONAL } This does not exactly match what I found here: http://vijairaj.blogspot.com/2009/01/parsing-and-using-custom-extension-in.html, but is taken from the exact specifications we need to comply to. This extension is not known to our OpenSSL version (0.9.8d) and I don't think later versions do know it?! Furthermore, the suggested code at the abovementioned article does not really fit into mod_ssl and I am hesitating to customize OpenSSL itself as well now. It should be possible to read and parse the extension by using ASN1 functions without defining the whole extension for OpenSSL, as it can be displayed with it's OID and raw data by "openssl asn1parse -in ", I think? What I am looking for is a feasible approach to doing so from within mod_ssl. Any help appreciated! In other news: what I achieved already is validating the certificate's signing algorithm and keylength, it's ExtendedKeyUsage data, the signing algorithm and the producedAt date of the OCSP response from within mod_ssl - if anybody is interested... I also 'fixed' the receipt of the actual OCSP response, which failed, if their was an empty line read at the beginning of the response, maybe due to a lag in traffic... (not valid code style according to Apache/httpd, I guess :( ). Mit freundlichen Grüßen / Kind regards Natanael Mignon IT - beraten | planen | umsetzen | betreiben __ michael-wessel.de Informationstechnologie GmbH Krausenstraße 50 30171 Hannover Germany fon (+49) 511 260 911-0 (DW -13) fax (+49) 511 318 039-9 eMailn...@michael-wessel.de web www.michael-wessel.de Geschäftsführer: Michael Wessel Dipl. Phys. Amtsgericht Hannover HR B 59031 Alle Produktnamen und Firmennamen sind ggfs. eingetragene Warenzeichen und/oder Markennamen der jeweiligen Hersteller. Angebote freibleibend, Irrtümer und Druckfehler vorbehalten. Lieferung vorbehaltlich ausreichender Selbstbelieferung. © 2009 michael-wessel.de __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Accessing unknown certificate extensions by OID
Dear list, another trial. ;) We need to validate the existence and value of an X.509 extension in a client certificate from within Apache/mod_ssl. The extension "Admission" is described by ISIS-MTT and has OID 1.3.36.8.3.3: AdmissionSyntax ::= SEQUENCE { admissionAuthority GeneralName OPTIONAL, contentsOfAdmissions SEQUENCE OF Admissions } Admissions ::= SEQUENCE { admissionAuthority [0] EXPLICIT GeneralName OPTIONAL, namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL, professionInfos SEQUENCE OF ProfessionInfo } NamingAuthority ::= SEQUENCE { namingAuthorityId OBJECT IDENTIFIER OPTIONAL, namingAuthorityUrl IA5String OPTIONAL, namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL} ProfessionInfo ::= SEQUENCE { namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, addProfessionInfo OCTET STRING OPTIONAL } This does not exactly match what I found here: http://vijairaj.blogspot.com/2009/01/parsing-and-using-custom-extension-in.html, but is taken from the exact specifications we need to comply to. This extension is not known to our OpenSSL version (0.9.8d) and I don't think later versions do know it?! Furthermore, the suggested code at the abovementioned article does not really fit into mod_ssl and I am hesitating to customize OpenSSL itself as well now. It should be possible to read and parse the extension by using ASN1 functions without defining the whole extension for OpenSSL, as it can be displayed with it's OID and raw data by "openssl asn1parse -in ", I think? What I am looking for is a feasible approach to doing so from within mod_ssl. Any help appreciated! In other news: what I achieved already is validating the certificate's signing algorithm and keylength, it's ExtendedKeyUsage data, the signing algorithm and the producedAt date of the OCSP response from within mod_ssl - if anybody is interested... I also 'fixed' the receipt of the actual OCSP response, which failed, if their was an empty line read at the beginning of the response, maybe due to a lag in traffic... (not valid code style according to Apache/httpd, I guess :( ). Mit freundlichen Grüßen / Kind regards Natanael Mignon IT - beraten | planen | umsetzen | betreiben __ michael-wessel.de Informationstechnologie GmbH Krausenstraße 50 30171 Hannover Germany fon (+49) 511 260 911-0 (DW -13) fax (+49) 511 318 039-9 eMailn...@michael-wessel.de web www.michael-wessel.de Geschäftsführer: Michael Wessel Dipl. Phys. Amtsgericht Hannover HR B 59031 Alle Produktnamen und Firmennamen sind ggfs. eingetragene Warenzeichen und/oder Markennamen der jeweiligen Hersteller. Angebote freibleibend, Irrtümer und Druckfehler vorbehalten. Lieferung vorbehaltlich ausreichender Selbstbelieferung. © 2009 michael-wessel.de __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Re: e-mail signing and certificate extensions
On Mon, Oct 06, 2008, Arsen Hayrapetyan wrote: > Dear list, > > If I understand correctly, there are two X.509 v3 extensions that determine > key (companion to the given certificate) suitability for e-mail signing: > > 1. extendedKeyUsage (EKU) > 2. nsCertType > nsCertType is obsolete now. It is retained for compatibility but its use is discouraged. > In particular, > 1. Setting only "emailProtection" in EKU > or > 2. Setting only "email" in nsCertType > gives > S/MIME signing : Yes > when the certificate is checked with "openssl x509 -in cert.pem -noout > -purpose" > > 3. When no EKU or nsCertType extension is present in cert, one gets: > S/MIME signing : Yes (why?) > Because the extension is a restriction on the key. If the extension is absent there is no restriction. > 4. If, e.g., "emailProtection" is NOT set in EKU and nsCertType is absent, > I get > S/MIME signing : No > > Can anyone explain, which combination of these two extensions results in a > key suitable for e-mail signing? > Do only these two extensions determine the suitability of the key for > e-mail signing? > The key usage digital signature and or the (can of worms) non-repudiation bits can restrict the key in general. So if key usage is present and both these bist are not set then chain validation for S/MIME signing (and any other signing) will fail. Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Homepage: http://www.drh-consultancy.demon.co.uk __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
e-mail signing and certificate extensions
Dear list, If I understand correctly, there are two X.509 v3 extensions that determine key (companion to the given certificate) suitability for e-mail signing: 1. extendedKeyUsage (EKU) 2. nsCertType In particular, 1. Setting only "emailProtection" in EKU or 2. Setting only "email" in nsCertType gives S/MIME signing : Yes when the certificate is checked with "openssl x509 -in cert.pem -noout -purpose" 3. When no EKU or nsCertType extension is present in cert, one gets: S/MIME signing : Yes (why?) 4. If, e.g., "emailProtection" is NOT set in EKU and nsCertType is absent, I get S/MIME signing : No Can anyone explain, which combination of these two extensions results in a key suitable for e-mail signing? Do only these two extensions determine the suitability of the key for e-mail signing? Thank you for your answers, Arsen. __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: Custom certificate extensions & CSR / cert creation: Missing field
Goetz Babin-Ebell schrieb: > >> The key is somehow wrong, but how? And why? > It contains only the public part of the key. > > The private part seems to get lost in between... You are so right. In the course of my copy&paste work of art, I reassigned pkey with... guess what? The certificate's public key. D'oh. Thanks a lot for pointing me in the correct direction. Regards, --ck __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: Custom certificate extensions & CSR / cert creation: Missing field
Hello Christopher, --On Mai 10, 2007 11:29:25 +0200 Christopher Kunz <[EMAIL PROTECTED]> wrote: I have isolated the problem to the private key that seems to be incorrectly generated. [...] -BEGIN RSA PRIVATE KEY- MIGKAgEAAoGBAJHprxsQfCcjF85LdJfDfSuudh/TuLCoLWgSTBnLJ8e98RmchH0Q frSEnoUmCFi+bpg2unr6pCi1gGD2VCWf4vs/JJgv5/op4R8KTKYPWjCoduoou+gM SG9GiJaKiJTRhfb7MaHkyk3wNaEpuzjF4mfJ0cq+8xtlxcoHDBVxeIepAgED -END RSA PRIVATE KEY- The private key is suspiciously short: openssl asn1parse -in key.pem 0:d=0 hl=3 l= 138 cons: SEQUENCE 3:d=1 hl=2 l= 1 prim: INTEGER :00 6:d=1 hl=3 l= 129 prim: INTEGER :91E9AF1B107C272317CE4B7497C37D2BAE761FD3B8B0A82D68124C19CB27C7BDF1199C847D107EB4849E85260858BE6E9836BA7AFAA428B58060F654259FE2FB3F24982FE7FA29E11F0A4CA60F5A30A876EA28BBE80C486F4688968A8894D185F6FB31A1E4CA4DF035A129BB38C5E267C9D1CABEF31B65C5CA070C15717887A9 138:d=1 hl=2 l= 1 prim: INTEGER :03 The key is somehow wrong, but how? And why? It contains only the public part of the key. The private part seems to get lost in between... Bye Goetz -- DMCA: The greed of the few outweights the freedom of the many pgpsNCCBr5ETu.pgp Description: PGP signature
Re: Custom certificate extensions & CSR / cert creation: Missing field
Hello, I have isolated the problem to the private key that seems to be incorrectly generated. When I take my self-created certificate and my self-created RSA key and try to convert them to PKCS#12, the following error occurs: [EMAIL PROTECTED] kunz]$ openssl pkcs12 -export -in testcert.pem -inkey testkey.pem -out test.p12 Error loading private key 22864:error:0D06B078:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:140: 22864:error:0D080065:asn1 encoding routines:d2i_ASN1_INTEGER:bad object header:a_int.c:204: 22864:error:0D09D082:asn1 encoding routines:d2i_RSAPrivateKey:parsing:d2i_r_pr.c:117: 22864:error:0D09B00D:asn1 encoding routines:d2i_PrivateKey:ASN1 lib:d2i_pr.c:89: 22864:error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib:pem_lib.c:291: The portion of my C code that generates the key and adds it to the certificate request looks like this (readers of the O'Reilly OpenSSL book will find this strangely familiar): keypair = RSA_generate_key(1024, RSA_3, NULL, NULL); if (!(RSA_check_key(keypair))) int_error("Error with keypair!"); pkey = EVP_PKEY_new(); if (!(EVP_PKEY_set1_RSA(pkey, keypair))) int_error("Error setting key to RSA"); if (!(req = X509_REQ_new ())) int_error("Error creating new request"); X509_REQ_set_pubkey (req, pkey); After all is said and done, the private key is written to the PEM file: if (!(PEM_write_PrivateKey(fp, pkey, NULL,NULL,0,0,NULL))) int_error ("Error writing private key"); We're not encrypting the key because the resulting proxy certificate chain is used for single-sign-on purposes in a Grid environment. We do need the key because we need to be able to delegate new proxy certificates based on the one that has just been generated. However, since the private key and certificate are basically throwaway items that are regenerated for each job submission, I feel no pain showing both to you. Impersonate me if you want, but do it quickly ;) -BEGIN CERTIFICATE- MIICGzCCAcWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBWMRMwEQYDVQQKEwpHZXJt YW5HcmlkMRQwEgYDVQQLEwtVbmlIYW5ub3ZlcjEZMBcGA1UEAxMQQ2hyaXN0b3Bo ZXIgS3VuejEOMAwGA1UEAxMFcHJveHkwHhcNMDcwNTEwMDg0MzQ5WhcNMDcwNTEw MjA0MzQ5WjBmMRMwEQYDVQQKEwpHZXJtYW5HcmlkMRQwEgYDVQQLEwtVbmlIYW5u b3ZlcjEZMBcGA1UEAxMQQ2hyaXN0b3BoZXIgS3VuejEOMAwGA1UEAxMFcHJveHkx DjAMBgNVBAMTBXByb3h5MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQCR6a8b EHwnIxfOS3SXw30rrnYf07iwqC1oEkwZyyfHvfEZnIR9EH60hJ6FJghYvm6YNrp6 +qQotYBg9lQln+L7PySYL+f6KeEfCkymD1owqHbqKLvoDEhvRoiWioiU0YX2+zGh 5MpN8DWhKbs4xeJnydHKvvMbZcXKBwwVcXiHqQIBA6MsMCowDgYDVR0PAQH/BAQD AgSwMBgGDCsGAQQBgY1dZAMCAQQIZm9vCmZvbwowDQYJKoZIhvcNAQEFBQADQQAm DzWVnPzJ8lwLL2ti5nZ4PzOYp+EZnROMemOaDJ/iX1X7YZ/kR8WaGr2NA+vzZhPL tp9fv6d7FQjjGOYHJ0b/ -END CERTIFICATE- -BEGIN RSA PRIVATE KEY- MIGKAgEAAoGBAJHprxsQfCcjF85LdJfDfSuudh/TuLCoLWgSTBnLJ8e98RmchH0Q frSEnoUmCFi+bpg2unr6pCi1gGD2VCWf4vs/JJgv5/op4R8KTKYPWjCoduoou+gM SG9GiJaKiJTRhfb7MaHkyk3wNaEpuzjF4mfJ0cq+8xtlxcoHDBVxeIepAgED -END RSA PRIVATE KEY- The key is somehow wrong, but how? And why? Regards, --ck __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: Custom certificate extensions & CSR / cert creation: Missing field
On Wed, May 09, 2007, Christopher Kunz wrote: > Dr. Stephen Henson schrieb: > > Hmmm that error shouldn't be encountered when you load a certificate. It > > suggests that you have an RSA private key but that it is in an invalid > > format. > > > I forgot to mention that openssl x509 -text -noout -in mycertchain.pem > does produce valid output, and seems to disregard the error that > prevents the certificate from actually being usable. To me that means > that it somehow has to be syntactically correct. I can provide you with > demo credentials if that is of any help - they are set to run out after > 12 hours anyway. :) > > Thanks for your help, > What I meant was that error looks like there is a private key in the file which is causing the function PEM_read_bio_X509_INFO() to fail when it attempts to read it rather than a certificate reading error or possibly that error is from a previous function call. Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Funding needed! Details on homepage. Homepage: http://www.drh-consultancy.demon.co.uk __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: Custom certificate extensions & CSR / cert creation: Missing field
Dr. Stephen Henson schrieb: > Hmmm that error shouldn't be encountered when you load a certificate. It > suggests that you have an RSA private key but that it is in an invalid format. > I forgot to mention that openssl x509 -text -noout -in mycertchain.pem does produce valid output, and seems to disregard the error that prevents the certificate from actually being usable. To me that means that it somehow has to be syntactically correct. I can provide you with demo credentials if that is of any help - they are set to run out after 12 hours anyway. :) Thanks for your help, --ck __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: Custom certificate extensions & CSR / cert creation: Missing field
On Wed, May 09, 2007, Christopher Kunz wrote: > I wrote an extremely simple program to check what might be wrong with > the certificate stack and this seems to be the problem: > > 15939:error:0D078079:asn1 encoding routines:ASN1_ITEM_EX_D2I:field > missing:tasn_dec.c:391:Field=d, Type=RSA > 15939:error:0907400D:PEM routines:PEM_X509_INFO_read_bio:ASN1 > lib:pem_info.c:224: > Hmmm that error shouldn't be encountered when you load a certificate. It suggests that you have an RSA private key but that it is in an invalid format. If you want to create custom extensions there is a much easier way now: the mini-ASN1 compiler as mentioned in the docs. Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Funding needed! Details on homepage. Homepage: http://www.drh-consultancy.demon.co.uk __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
Custom certificate extensions & CSR / cert creation: Missing field
Hi, I am using the examples from the O'Reilly book "Network Security with OpenSSL" (X.509 section) to create a CSR, push a custom extension into it and sign that CSR with a given private key. This - in general - works OK, but when I want to use the resulting certificate chain (I have the signing certificate and a couple more in there) for anything secure (i.e. mutual authentication), I am greeted with failure. I wrote an extremely simple program to check what might be wrong with the certificate stack and this seems to be the problem: 15939:error:0D078079:asn1 encoding routines:ASN1_ITEM_EX_D2I:field missing:tasn_dec.c:391:Field=d, Type=RSA 15939:error:0907400D:PEM routines:PEM_X509_INFO_read_bio:ASN1 lib:pem_info.c:224: I figure that there is something wrong with the way I create the ASN.1 object and push it onto the extension stack for the CSR. This looks like so in my code: ASN1_OBJECT *obj; ASN1_OCTET_STRING *ex_oct = NULL; X509_EXTENSION *ex_execpol = NULL; new_nid = OBJ_create(EXECPOLICY_OID, EXECPOLICY_SN, EXECPOLICY_LN); obj = OBJ_nid2obj(new_nid); if (!(ex_oct = ASN1_OCTET_STRING_new())) { int_error("Error creating custom ASN.1 struct"); } extlist = sk_X509_EXTENSION_new_null(); ASN1_OCTET_STRING_set(ex_oct,policy,-1); if (!(ex_execpol = X509_EXTENSION_create_by_OBJ(&ex_execpol, obj, 0, ex_oct))) { //3rd parameter is critical/noncritical int_error("Error creating X509 extension for execpolicy"); } if (!(sk_X509_EXTENSION_push (extlist, ex_execpol))) { int_error("Error pushing custom extension to stack"); } if (!(X509_REQ_add_extensions (req, extlist))) { int_error ("Error adding ExecPolicy to the request"); } sk_X509_EXTENSION_pop_free (extlist, X509_EXTENSION_free); } Later, I am getting the extension stack from the CSR... if (!(req_exts = X509_REQ_get_extensions (req))) int_error ("Error getting the request's extensions"); int new_nid; ASN1_OBJECT *obj; new_nid = OBJ_create(EXECPOLICY_OID, EXECPOLICY_SN, EXECPOLICY_LN); execPolicy_pos = X509v3_get_ext_by_NID (req_exts, new_nid, -1); execPolicy = X509v3_get_ext (req_exts, execPolicy_pos); fputc ('\n', stdout); ...and add them to the certificate before signing: /* add x509v3 extensions as specified */ X509V3_set_ctx (&ctx, CAcert, cert, NULL, NULL, 0); for (i = 0; i < EXT_COUNT; i++) { X509_EXTENSION *ext; if (!(ext = X509V3_EXT_conf (NULL, &ctx, ext_ent[i].key, ext_ent[i].value))) { fprintf (stderr, "Error on \"%s = %s\"\n", ext_ent[i].key, ext_ent[i].value); int_error ("Error creating X509 extension object"); } // Mark purpose as critical if (!(X509_EXTENSION_set_critical (ext, 1))) { fprintf(stderr, "Error setting Extension to critical: %s", ext_ent[i].key); int_error("Error setting Extension to critical"); } if (!X509_add_ext (cert, ext, -1)) { fprintf (stderr, "Error on \"%s = %s\"\n", ext_ent[i].key, ext_ent[i].value); int_error ("Error adding X509 extension to certificate"); } X509_EXTENSION_free (ext); } /* add the extension in the request to the cert */ if (!X509_add_ext (cert, execPolicy, -1)) int_error ("etc"); Is there anything I am doing horribly wrong along the way? Any pointers where the missing field could be? I guess it can only be in the custom ASN.1 structure I have created for my own extension. Regards and thanks, --ck __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: DSA signatures and custom (X.509) certificate extensions
On Mon, Mar 17, 2003, Henrik Grindal Bakken wrote: > "Dr. Stephen Henson" <[EMAIL PROTECTED]> writes: > > > On Thu, Mar 13, 2003, Henrik Grindal Bakken wrote: > > > >> Firstly, I want to make a signature on a file using a DSA key-pair. > >> I can do this for an RSA pair with 'openssl rsautl', but is there > >> something similar for DSA, or do I have to write it myself? > > > > rsautl takes 'raw' signatures rather than signing digests. > > > > The dgst utility digests data and has options to sign the > > digest. You can signing using DSA with the -dss1 digest > > (SHA1+DSA). Check out the manual pages for more info. > > Ah, thanks. I looked at it, and tried, but couldn't verify the > signature. I discovered later that -binary might have been a good > idea... Is there much difference between using smime with detached > signature and -outform pem and using dgst? > Yes dgst is just a raw DSA signature and things like the public key to verify the signature with have to be determined by other means. The smime signature uses S/MIME format which encapsulates the signature and associated certificate in PKCS#7 format. > >> Second question: I want to issue a version 3 X.509 certificate from > >> my own (testing purposes only) CA, with a custom extension. The > >> extension value should be a string (although that is not > >> important). Do I have to write my own code here, or can the > >> current application do this? > > > > There are some string extension already available such as netscape > > comment whic may suit. > > I noticed that, and I could use it for testing purposes, but for a > more final version, it doesn't really suffice. > > > If you really want a custom extension. You can do this with 0.9.7 > > but you have to work out the encoding yourself and place the hex > > form in the DER option. > > Hmm. A bit awkward. I did find the doc/openssl.txt (or whatever the > name was) file, and I read it a little, but figured I didn't have time > to do this properly at the moment. > > > With 0.9.8-dev you can use a human readable syntax such as: > > > > myextension = ASN1:UTF8:My Extension string > > Looks better, less messy. > > Is there any estimate of when 0.9.8 will be ready? Is it safe to use > for a not-very-critical project now? > No there's no timetable in 0.9.8. All I can say is probably not soon. Its a moving target and while the today's version may be pretty stable tomorrow's may not :-) > > You can actually use the asn1parse utility in 0.9.8 to dump out the > > DER version which you could then place in a 0.9.7 config file. > > Hmm. That sounds like an idea. Thanks for the suggestions. > You could do something like: openssl asn1parse -genstr "UTF8:my string" -noout -out extension.der then do a hex dump of extension.der which you can include in 0.9.7. Steve. -- Dr Stephen N. Henson. Core developer of the OpenSSL project: http://www.openssl.org/ Freelance consultant see: http://www.drh-consultancy.demon.co.uk/ Email: [EMAIL PROTECTED], PGP key: via homepage. __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
Re: DSA signatures and custom (X.509) certificate extensions
"Dr. Stephen Henson" <[EMAIL PROTECTED]> writes: > On Thu, Mar 13, 2003, Henrik Grindal Bakken wrote: > >> Firstly, I want to make a signature on a file using a DSA key-pair. >> I can do this for an RSA pair with 'openssl rsautl', but is there >> something similar for DSA, or do I have to write it myself? > > rsautl takes 'raw' signatures rather than signing digests. > > The dgst utility digests data and has options to sign the > digest. You can signing using DSA with the -dss1 digest > (SHA1+DSA). Check out the manual pages for more info. Ah, thanks. I looked at it, and tried, but couldn't verify the signature. I discovered later that -binary might have been a good idea... Is there much difference between using smime with detached signature and -outform pem and using dgst? >> Second question: I want to issue a version 3 X.509 certificate from >> my own (testing purposes only) CA, with a custom extension. The >> extension value should be a string (although that is not >> important). Do I have to write my own code here, or can the >> current application do this? > > There are some string extension already available such as netscape > comment whic may suit. I noticed that, and I could use it for testing purposes, but for a more final version, it doesn't really suffice. > If you really want a custom extension. You can do this with 0.9.7 > but you have to work out the encoding yourself and place the hex > form in the DER option. Hmm. A bit awkward. I did find the doc/openssl.txt (or whatever the name was) file, and I read it a little, but figured I didn't have time to do this properly at the moment. > With 0.9.8-dev you can use a human readable syntax such as: > > myextension = ASN1:UTF8:My Extension string Looks better, less messy. Is there any estimate of when 0.9.8 will be ready? Is it safe to use for a not-very-critical project now? > You can actually use the asn1parse utility in 0.9.8 to dump out the > DER version which you could then place in a 0.9.7 config file. Hmm. That sounds like an idea. Thanks for the suggestions. -- Henrik Grindal Bakken <[EMAIL PROTECTED]> PGP ID: 8D436E52 Fingerprint: 131D 9590 F0CF 47EF 7963 02AF 9236 D25A 8D43 6E52 __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
Certificate extensions
I have couple of questions about X.509 v3 certificates in general. I have a system in which we were communicating keys using files/records. I now want to migrate to certificates. There are fields in the record which do not have a corresponding extension in X.509 spec. How can i encode them in a certificate ? Is it possible at all to do so by having user specified Extensions in the certificate ? If yes, then what are the OIDs i can use and how to go about with the encoding ? Can the Extended Key Usage field have user defined Key Purpose Ids ? I will be having my own parser to parse the certificates but i would like to be as close to the X.509 spec as possible. Thanks, - Pooja __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
Re: Certificate Extensions
Jorge wrote: > > Hello all, > I'm trying to include an URL to a CRL in my client certificates. My clients > use both netscape and explorer, so I can't use nsRevocationUrl. I've already > checked documentation, and found that the extension I must use is > CRLDistributionPoints (OID:2.5.29.31). > My problem is that I can't make it work. If I insert a line in openssl.cnf > like crlDistPoints = http://... I get the following error message: > 27841:error:2207C082:X509 V3 routines:DO_EXT_CONF:unknown extension > name:v3_conf > .c:121: > 27841:error:2206B080:X509 V3 routines:X509V3_EXT_conf:error in > extension:v3_conf > .c:91:name=crlDistPoints, value=http://www.foo.bar/cgi-bin/rev.cgi > > How can I make it work? > If you read the FAQ you'd see it mentions documentation in doc/openssl.txt. This documentation includes examples of the use of this extension. Steve. -- Dr Stephen N. Henson. http://www.drh-consultancy.demon.co.uk/ Personal Email: [EMAIL PROTECTED] Senior crypto engineer, Celo Communications: http://www.celocom.com/ Core developer of the OpenSSL project: http://www.openssl.org/ Business Email: [EMAIL PROTECTED] PGP key: via homepage. __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
Certificate Extensions
Hello all, I'm trying to include an URL to a CRL in my client certificates. My clients use both netscape and explorer, so I can't use nsRevocationUrl. I've already checked documentation, and found that the extension I must use is CRLDistributionPoints (OID:2.5.29.31). My problem is that I can't make it work. If I insert a line in openssl.cnf like crlDistPoints = http://... I get the following error message: 27841:error:2207C082:X509 V3 routines:DO_EXT_CONF:unknown extension name:v3_conf .c:121: 27841:error:2206B080:X509 V3 routines:X509V3_EXT_conf:error in extension:v3_conf .c:91:name=crlDistPoints, value=http://www.foo.bar/cgi-bin/rev.cgi How can I make it work? Thanx in advance Jorge __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]