Re: get subjectAltName

2010-09-22 Thread Naveen B.N

Resending with attachment ..

Naveen B.N wrote:

Hello,
I am using Linux.
I am trying to print the subjectAltName present in the certificate, 
but i am seeing crash in /lib/libcrypto.so.6

core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
(gdb) bt
#0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
#1  0x0593a786 in X509v3_get_ext_by_OBJ () from /lib/libcrypto.so.6
#2  0x0593a7ce in X509v3_get_ext_by_NID () from /lib/libcrypto.so.6
#3  0x08048870 in find_root_cert (in=0x9445a72 , len=1002) at 
find_root.c:37

#4  0x080489af in main () at find_root.c:65

Help me to solve this issue. Please guide, if any other alternative to 
method to achieve the same

Please find the code used below and certificate is attached.

Thanks and Regards
Naveen

/  Start code ***/int find_root_cert(char 
*in,int len)

{
X509 *cert1=NULL;
X509_NAME *name;
char *buffer;   
X509_EXTENSION *ext=NULL;

char *test;
int pos=0,nid;

cert1=d2i_X509(NULL,in,len);
printf(\n cert=%x , cert1);
name=X509_get_subject_name(cert1);
buffer=X509_NAME_oneline(name, 0, 0);
if(strstr(buffer,CN=kdc.globaledgesoft.com)==NULL)
return -1;
else
{   
 *   nid=OBJ_sn2nid(subjectAltName);
pos=X509v3_get_ext_by_NID (cert1,OBJ_sn2nid(subjectAltName), 
-1);

  ext=X509v3_get_ext(cert1,pos);
if(ext!=NULL){
test=d2i_ASN1_IA5STRING(ext-value-data,NULL,0);
printf(\n test =%s , test);*
}
return 0;
}
}

int main(int argc, char **argv)
{
const unsigned char *in ;
int len,size,ret;
X509 *cert1=NULL;
X509 *cert2=NULL;
FILE   *fp;
struct stat st;

fp = fopen(kdc.cer,r);
stat ( (const char *)kdc.cer,st);
size = st.st_size;
in=(unsigned char *)malloc(++size);
printf(\n length = %d ,size);
len=fread(in,1,size,fp);
fclose(fp);
printf(\n Len =%d,len);
printf(\n cert=%x , cert1);
if(find_root_cert(in,len)==0)
printf(\n This is the Root\n);
else
printf(\n No match was found \n);
}

/* End /




kdc.cer
Description: application/x509-ca-cert


get subjectAltName

2010-09-22 Thread Naveen B.N

Hello,
I am using Linux.
I am trying to print the subjectAltName present in the certificate, but 
i am seeing crash in /lib/libcrypto.so.6

core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
(gdb) bt
#0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
#1  0x0593a786 in X509v3_get_ext_by_OBJ () from /lib/libcrypto.so.6
#2  0x0593a7ce in X509v3_get_ext_by_NID () from /lib/libcrypto.so.6
#3  0x08048870 in find_root_cert (in=0x9445a72 , len=1002) at 
find_root.c:37

#4  0x080489af in main () at find_root.c:65

Help me to solve this issue. Please guide, if any other alternative to 
method to achieve the same

Please find the code used below.

Thanks and Regards
Naveen

/  Start code ***/int find_root_cert(char 
*in,int len)

{
   X509 *cert1=NULL;
   X509_NAME *name;
   char *buffer;   X509_EXTENSION *ext=NULL;
   char *test;
   int pos=0,nid;

   cert1=d2i_X509(NULL,in,len);
   printf(\n cert=%x , cert1);
   name=X509_get_subject_name(cert1);
   buffer=X509_NAME_oneline(name, 0, 0);
   if(strstr(buffer,CN=kdc.globaledgesoft.com)==NULL)
   return -1;
   else
   {*   nid=OBJ_sn2nid(subjectAltName);
   pos=X509v3_get_ext_by_NID (cert1,OBJ_sn2nid(subjectAltName), -1);
 ext=X509v3_get_ext(cert1,pos);
   if(ext!=NULL){
   test=d2i_ASN1_IA5STRING(ext-value-data,NULL,0);
   printf(\n test =%s , test);*
   }
   return 0;
   }
}

int main(int argc, char **argv)
{
   const unsigned char *in ;
   int len,size,ret;
   X509 *cert1=NULL;
   X509 *cert2=NULL;
   FILE   *fp;
   struct stat st;

   fp = fopen(kdc.cer,r);
   stat ( (const char *)kdc.cer,st);
   size = st.st_size;
   in=(unsigned char *)malloc(++size);
   printf(\n length = %d ,size);
   len=fread(in,1,size,fp);
   fclose(fp);
   printf(\n Len =%d,len);
   printf(\n cert=%x , cert1);
   if(find_root_cert(in,len)==0)
   printf(\n This is the Root\n);
   else
   printf(\n No match was found \n);
}

/* End /
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: get subjectAltName

2010-09-22 Thread Christian Hohnstaedt
On Wed, Sep 22, 2010 at 02:40:26PM +0530, Naveen B.N wrote:
 Hello,
 I am using Linux.
 I am trying to print the subjectAltName present in the certificate, but 
 i am seeing crash in /lib/libcrypto.so.6
 core was generated by `./a.out'.
 Program terminated with signal 11, Segmentation fault.
 #0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
 (gdb) bt
 #0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
 #1  0x0593a786 in X509v3_get_ext_by_OBJ () from /lib/libcrypto.so.6
 #2  0x0593a7ce in X509v3_get_ext_by_NID () from /lib/libcrypto.so.6
 #3  0x08048870 in find_root_cert (in=0x9445a72 , len=1002) at 
 find_root.c:37
 #4  0x080489af in main () at find_root.c:65
 
 Help me to solve this issue. Please guide, if any other alternative to 
 method to achieve the same
 Please find the code used below.

First hint: look at the warnings issued by the compiler.
They usually indicate you are doing something wrong.

 
 Thanks and Regards
 Naveen
 
 /  Start code ***/int find_root_cert(char 
 *in,int len)
 {
X509 *cert1=NULL;
X509_NAME *name;
char *buffer;   X509_EXTENSION *ext=NULL;
char *test;
int pos=0,nid;
 
cert1=d2i_X509(NULL,in,len);
printf(\n cert=%x , cert1);
name=X509_get_subject_name(cert1);
buffer=X509_NAME_oneline(name, 0, 0);
if(strstr(buffer,CN=kdc.globaledgesoft.com)==NULL)
return -1;
else
{*   nid=OBJ_sn2nid(subjectAltName);
pos=X509v3_get_ext_by_NID (cert1,OBJ_sn2nid(subjectAltName), -1);

/* no need to translate constant string (subjectAltName) to NID
   Use the nid constant directly: NID_subject_alt_name
   X509v3_get_ext_by_NID() expects a pointer to extensions
   X509_get_ext_by_NID() expects a cert as first argument
*/
pos=X509_get_ext_by_NID (cert1, NID_subject_alt_name, -1);

/* need to check for existance of subjectAltName */
if (pos == -1)
   ERROR();
   
  ext=X509v3_get_ext(cert1,pos);

Same as above: use X509_get_ext() instead.
The compiler told you about incompatible pointer types. Don't ignore it.

if(ext!=NULL){
test=d2i_ASN1_IA5STRING(ext-value-data,NULL,0);

It is not that easy

The subaltname is tagged as otherName in the kdc.cer
You need to parse the othername, which contains the OID
1.3.6.1.5.2.2
which indicates a DER encoded KRB5PrincipalName
search Google for the OID


Cheers
Christian

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Win CE 6.0 + ARM + openssl

2010-09-22 Thread Jakob Bohm

On 21-09-2010 18:48, Jean-Marc Desperrier wrote:

Jakob Bohm wrote:

1. The current README.WCE and code assumes that you link with one of
two less free libraries (one is LGPL, the other requires reconfiguration
of the target device/phone). I wrote my own more minimal library
under the OpenSSL license to avoid them both. This obviously implied
patching OpenSSL to use the new library rather than one of the two
old ones.


Why does it mean patching OpenSSL ? wcecompat seems to be just providing
some stdlib function not available by default on WCE, so isn't your
library just an alternative implementation of those functions ? If not,
then why ?



The os dependency files in openssl assume specifics of either 
wcecompat or the other restricted library, I have simply added 
alternative cases for my simpler cedummy library.


My cedummy library provides much fewer libc function replacements than
wcecompat, relying instead on windows CE's standard libc and adding
just a few missing functions (such as gmtime()).


I suggest you put your lib on sourceforge or google code, and just
provide the openssl patch. But I think your patch to openssl is much
more likely to be accepted if you keep it as small as possible.
If it's not small, maybe it's better, in a first step at least, to leave
it together with the library on an external repository.



Yes, it needs trimming and cleanup to keep the patch minimal, which is
why I have not posted it yet.  The initial home of the library will
probably be on one of our own sites.


2. To simplify installation of my program, I prefer static linking of
OpenSSL. This turned up a number of general (not WinCE specific) design
issues in EVP and ASN code, resulting in massive bloat of programs that
don't use all of OpenSSL. Basically, lots of .o files are pulled in
by just-in-case calls (mostly XXX_free() functions), table-driven
selection of which code to execute and other such bad practices.
Using a number of ad-hoc patches I managed to cut down some of the
overhead, but its not very clean or efficient yet.


Could you provide this as a separate patch, that you would call openssl
code reorganization to optimize for use on embedded platforms ?



This part is actually the largest part (in kilobytes) of my private 
patch.  This is not as much about embedded platforms as it is about

static linking to openssl (on any platform where a recent openssl shared
library is not included by default, including desktop systems).


I think this discussion should continue on openssl-dev instead of -users.


Maybe it should, I am not subscribed there, as the list description
clearly dissuaded library users like myself from using that list.  But
maybe.

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


LNK4078 and LNK4210 linking with x64 static libs

2010-09-22 Thread per fry kenvall
Hi, (please excuse if this is a duplicate, yesterdays posting 
seems failed)


I have problems with warnings from the linker on Windows, indicating 
that initializers will not be called. I've built 1.0.0a with VS2005, 
using nt.mak to get static libraries.


With x64 I get warnings when linking applications, both openssl.exe and 
test programs like sha1test.exe. A snippet of output from nmake -f 
ms\nt.mak:
  link /nologo /subsystem:console /opt:ref /debug 
/out:out32\openssl.exe @C:\DOCUME~1\FRYKEN~1\LOCALS~1\Temp\nm3B3.tmp
LIBCMT.lib(crt0init.obj) : warning LNK4254: section '.CRT' (6020) 
merged into '.rdata' (4040) with different attributes



And when linking our own application on x64/Release platform:
  libeay32.lib(x86_64cpuid.obj) : warning LNK4078: multiple '.CRT' 
sections found with different attributes (60500020)
  libeay32.lib(x86_64cpuid.obj) : warning LNK4210: .CRT section exists; 
there may be unhandled static initializers or terminators



The linker command can be deduced from the following:
  Creating temporary file 
c:\utv\ccbas4\ccbase\x64\Release\RSP132444832.rsp with contents

  [
  /OUT:../deploy/execs/x64/Release/etnode.exe /INCREMENTAL:NO 
/MANIFEST /MANIFESTFILE:x64/Release\etnode.exe.intermediate.manifest 
/DELAYLOAD:oci.dll /DEBUG 
/PDB:../deploy/execs/x64/Release/etnode.pdb /SUBSYSTEM:CONSOLE /LTCG 
psapi.lib odbc32.lib odbccp32.lib WS2_32.LIB ADVAPI32.LIB GDI32.LIB 
USER32.LIB dbghelp.lib 
../snibu/logging-log4cxx/msvc/lib/x64/Release/log4cxxs.lib 
../snibu/openssl-1.0.0a/x64/Release/lib/ssleay32.lib 
../snibu/openssl-1.0.0a/x64/Release/lib/libeay32.lib 
../snibu/oracle/x64/instantclient_10_2/sdk/lib/msvc/oci.lib 
../snibu/zlib/msvc/lib/x64/Release/zlibstat.lib kernel32.lib user32.lib 
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib


  .\x64\Release\CCcServApp.obj
  ...
  .\x64\Release\Bas4Bridge.obj
  ]
  Creating command line link.exe 
@c:\utv\ccbas4\ccbase\x64\Release\RSP132444832.rsp /NOLOGO 
/ERRORREPORT:PROMPT



I've done the following to build openssl:
  cd /d C:\utv\snibu\openssl\x64\release\openssl-1.0.0a
  call C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat 
x86_amd64

  perl Configure VC-WIN64A --prefix=c:\appl\openssl-1.0.0a\x64\release
  ms\do_win64a.bat
  nmake -f ms\nt.mak
  nmake -f ms\nt.mak install

And the file x86_64cpuid.asm mentioned in the warnings starts with the 
following:

  defaultrel
  EXTERNOPENSSL_cpuid_setup
  section.CRT$XCU
  ALIGN8
  DQOPENSSL_cpuid_setup

  section.text code align=64
...


Could somebody help me solve this warning, it seems to me that 
OPENSSL_cpuid_setup will not be executed.



Best regards,
Per Frykenvall


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: get subjectAltName

2010-09-22 Thread Naveen B.N

Thank you Christian,
your suggestions helped us to get the position but as you mentioned the 
problem
of resolving to kerberos principal name, i tried Google and added a 
piece  of code

but i am not getting the out put  as  shown below .

#include stdio.h
#include string.h

#include openssl/sha.h
#include openssl/hmac.h
#include openssl/evp.h
#include openssl/bio.h
#include openssl/buffer.h
#include openssl/x509.h
#include openssl/x509v3.h
#include sys/types.h
#include sys/stat.h
#include unistd.h

#define CERT_INFO_MAX_ENTRIES 15
#define CERT_INFO_SIZE 10
static char **cert_info_kpn(X509 *x509) {
   int i,j;
   static char *entries[CERT_INFO_SIZE];
   STACK_OF(GENERAL_NAME) *gens;
   GENERAL_NAME *name;
   ASN1_OBJECT *krb5PrincipalName;
   printf(Trying to find a Kerberos Principal Name in 
certificate);

   gens = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, NULL);
   krb5PrincipalName = OBJ_txt2obj(1.3.6.1.5.2.2, 1);
   if (!gens) {
   printf(No alternate name extensions);
   return NULL; /* no alternate names */
   }
   if (!krb5PrincipalName) {
   printf(Cannot map KPN object);
   return NULL;
   }
   for (i=0,j=0; (i  sk_GENERAL_NAME_num(gens))  
(jCERT_INFO_MAX_ENTRIES); i++) {

   name = sk_GENERAL_NAME_value(gens, i);
   if ( name  name-type==GEN_OTHERNAME ) {  /* test for 
UPN */
   if (OBJ_cmp(name-d.otherName-type_id, 
krb5PrincipalName)) continue; /* object is not a UPN */

   else {
   /* NOTE:
   from PKINIT RFC, I deduce that stored format for 
kerberos

   Principal Name is ASN1_STRING, but not sure at 100%
   Any help will be granted
   */
   unsigned char *txt;
   ASN1_TYPE *val = name-d.otherName-value;
   ASN1_STRING *str= val-value.asn1_string;
   printf(Found Kerberos Principal Name );
   if ( ( ASN1_STRING_to_UTF8(txt, str) )  0) {
   printf(ASN1_STRING_to_UTF8() failed: %s, 
ERR_error_string(ERR_get_error(),NULL));

   } else {
   printf(Adding KPN entry: %s,txt);
   //entries[j++]= clone_str((const char *)txt);
   }
   }
   }
   }
   sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free);
   ASN1_OBJECT_free(krb5PrincipalName);
   if(j==0) {
   printf(Certificate does not contain a KPN entry);
   return NULL;
   }
   return entries;
}

int find_root_cert(const unsigned char **in,int len)
{
   X509 *cert1=NULL;
   X509_NAME *name;
   char *buffer;   
   X509_EXTENSION *ext=NULL;

   char *test;
   int pos=0,nid;

   cert1=d2i_X509(NULL,in,len);
   printf(\n cert=%x , cert1);
   name=X509_get_subject_name(cert1);
   buffer=X509_NAME_oneline(name, 0, 0);
   if(strstr(buffer,CN=kdc.globaledgesoft.com)==NULL)
   return -1;
   else
   {   
#if 0

   pos=X509_get_ext_by_NID(cert1,NID_subject_alt_name, -1);
   if (pos == -1){
   printf(\n pos == -1 \n);
   return -1;
   }
 ext=X509_get_ext(cert1,pos);
   if(ext!=NULL){
   test=(char *)d2i_ASN1_IA5STRING((ASN1_IA5STRING 
**)ext-value-data,NULL,0);

   printf(\n test =%s , test);
   }
#endif
   cert_info_kpn(cert1);
   return 0;
   }
}

int main(int argc, char **argv)
{
   const unsigned char *in ;
   int len,size,ret;
   X509 *cert1=NULL;
   X509 *cert2=NULL;
   FILE   *fp;
   struct stat st;

   fp = fopen(KDC.cer,r);
   stat ( (const char *)KDC.cer,st);
   size = st.st_size;
   in=(unsigned char *)malloc(++size);
   printf(\n length = %d ,size);
   len=fread((void *)in,1,size,fp);
   fclose(fp);
   printf(\n Len =%d,len);
   printf(\n cert=%x , cert1);
   if(find_root_cert(in,len)==0)
   printf(\n This is the Root\n);
   else
   printf(\n No match was found \n);
}


/* output */

length = 1001
Len =1000
cert=0
cert=86da458 Trying to find a Kerberos Principal Name in 
certificateFound Kerberos Principal Name ASN1_STRING_to_UTF8() failed: 
error::lib(0):func(0):reason(0)Certificate does not contain a 
KPN entry

This is the Root

Thanks in advance .

Regards
Naveen


Christian Hohnstaedt wrote:

On Wed, Sep 22, 2010 at 02:40:26PM +0530, Naveen B.N wrote:
  

Hello,
I am using Linux.
I am trying to print the subjectAltName present in the certificate, but 
i am seeing crash in /lib/libcrypto.so.6

core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
(gdb) bt
#0  0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
#1  0x0593a786 in X509v3_get_ext_by_OBJ 

Re: get subjectAltName

2010-09-22 Thread Naveen B.N

Attaching  the PEM format certificate used ,
We need to convert it to DER before using it with the below given code.
Command to convert PEM to DER
openssl x509 -inform PEM -in KDC.pem -outform DER -out KDC.cer

Thanks and Regards
Naveen
Naveen B.N wrote:

Thank you Christian,
your suggestions helped us to get the position but as you mentioned 
the problem
of resolving to kerberos principal name, i tried Google and added a 
piece  of code

but i am not getting the out put  as  shown below .

#include stdio.h
#include string.h

#include openssl/sha.h
#include openssl/hmac.h
#include openssl/evp.h
#include openssl/bio.h
#include openssl/buffer.h
#include openssl/x509.h
#include openssl/x509v3.h
#include sys/types.h
#include sys/stat.h
#include unistd.h

#define CERT_INFO_MAX_ENTRIES 15
#define CERT_INFO_SIZE 10
static char **cert_info_kpn(X509 *x509) {
   int i,j;
   static char *entries[CERT_INFO_SIZE];
   STACK_OF(GENERAL_NAME) *gens;
   GENERAL_NAME *name;
   ASN1_OBJECT *krb5PrincipalName;
   printf(Trying to find a Kerberos Principal Name in 
certificate);
   gens = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, 
NULL);

   krb5PrincipalName = OBJ_txt2obj(1.3.6.1.5.2.2, 1);
   if (!gens) {
   printf(No alternate name extensions);
   return NULL; /* no alternate names */
   }
   if (!krb5PrincipalName) {
   printf(Cannot map KPN object);
   return NULL;
   }
   for (i=0,j=0; (i  sk_GENERAL_NAME_num(gens))  
(jCERT_INFO_MAX_ENTRIES); i++) {

   name = sk_GENERAL_NAME_value(gens, i);
   if ( name  name-type==GEN_OTHERNAME ) {  /* test for 
UPN */
   if (OBJ_cmp(name-d.otherName-type_id, 
krb5PrincipalName)) continue; /* object is not a UPN */

   else {
   /* NOTE:
   from PKINIT RFC, I deduce that stored format 
for kerberos
   Principal Name is ASN1_STRING, but not sure at 
100%

   Any help will be granted
   */
   unsigned char *txt;
   ASN1_TYPE *val = name-d.otherName-value;
   ASN1_STRING *str= val-value.asn1_string;
   printf(Found Kerberos Principal Name );
   if ( ( ASN1_STRING_to_UTF8(txt, str) )  0) {
   printf(ASN1_STRING_to_UTF8() failed: %s, 
ERR_error_string(ERR_get_error(),NULL));

   } else {
   printf(Adding KPN entry: %s,txt);
   //entries[j++]= clone_str((const char *)txt);
   }
   }
   }
   }
   sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free);
   ASN1_OBJECT_free(krb5PrincipalName);
   if(j==0) {
   printf(Certificate does not contain a KPN entry);
   return NULL;
   }
   return entries;
}

int find_root_cert(const unsigned char **in,int len)
{
   X509 *cert1=NULL;
   X509_NAME *name;
   char *buffer;  X509_EXTENSION *ext=NULL;
   char *test;
   int pos=0,nid;

   cert1=d2i_X509(NULL,in,len);
   printf(\n cert=%x , cert1);
   name=X509_get_subject_name(cert1);
   buffer=X509_NAME_oneline(name, 0, 0);
   if(strstr(buffer,CN=kdc.globaledgesoft.com)==NULL)
   return -1;
   else
   {   #if 0
   pos=X509_get_ext_by_NID(cert1,NID_subject_alt_name, -1);
   if (pos == -1){
   printf(\n pos == -1 \n);
   return -1;
   }
 ext=X509_get_ext(cert1,pos);
   if(ext!=NULL){
   test=(char *)d2i_ASN1_IA5STRING((ASN1_IA5STRING 
**)ext-value-data,NULL,0);

   printf(\n test =%s , test);
   }
#endif
   cert_info_kpn(cert1);
   return 0;
   }
}

int main(int argc, char **argv)
{
   const unsigned char *in ;
   int len,size,ret;
   X509 *cert1=NULL;
   X509 *cert2=NULL;
   FILE   *fp;
   struct stat st;

   fp = fopen(KDC.cer,r);
   stat ( (const char *)KDC.cer,st);
   size = st.st_size;
   in=(unsigned char *)malloc(++size);
   printf(\n length = %d ,size);
   len=fread((void *)in,1,size,fp);
   fclose(fp);
   printf(\n Len =%d,len);
   printf(\n cert=%x , cert1);
   if(find_root_cert(in,len)==0)
   printf(\n This is the Root\n);
   else
   printf(\n No match was found \n);
}


/* output */

length = 1001
Len =1000
cert=0
cert=86da458 Trying to find a Kerberos Principal Name in 
certificateFound Kerberos Principal Name ASN1_STRING_to_UTF8() failed: 
error::lib(0):func(0):reason(0)Certificate does not contain a 
KPN entry

This is the Root

Thanks in advance .

Regards
Naveen


Christian Hohnstaedt wrote:

On Wed, Sep 22, 2010 at 02:40:26PM +0530, Naveen B.N wrote:
 

Hello,
I am using Linux.
I am trying to print the subjectAltName present in the certificate, 
but i am seeing crash in 

Re: get subjectAltName

2010-09-22 Thread Christian Hohnstaedt
On Wed, Sep 22, 2010 at 05:48:07PM +0530, Naveen B.N wrote:
 Thank you Christian,
 your suggestions helped us to get the position but as you mentioned the 
 problem
 of resolving to kerberos principal name, i tried Google and added a 
 piece  of code
 but i am not getting the out put  as  shown below .
 
 #include stdio.h
 #include string.h
 
 #include openssl/sha.h
 #include openssl/hmac.h
 #include openssl/evp.h
 #include openssl/bio.h
 #include openssl/buffer.h
 #include openssl/x509.h
 #include openssl/x509v3.h
 #include sys/types.h
 #include sys/stat.h
 #include unistd.h
 
 #define CERT_INFO_MAX_ENTRIES 15
 #define CERT_INFO_SIZE 10

/*
  http://www.h5l.org/manual/HEAD/info/heimdal/Setting-up-PK_002dINIT.html

KRB5PrincipalName ::= SEQUENCE {
realm [0] Realm,
principalName [1] PrincipalName
 }

Maybe this is already defined somewhere in OpenSSL - I didn't find it.
*/

typedef struct kdc_princname_st
{
ASN1_GENERALSTRING  *realm;
KRB5_PRINCNAME  *princname;
}   KDC_PRINCNAME;

ASN1_SEQUENCE(KDC_PRINCNAME) = {
ASN1_EXP(KDC_PRINCNAME, realm, ASN1_GENERALSTRING, 0),
ASN1_EXP(KDC_PRINCNAME, princname, KRB5_PRINCNAME, 1)
} ASN1_SEQUENCE_END(KDC_PRINCNAME)

IMPLEMENT_ASN1_FUNCTIONS(KDC_PRINCNAME)


 static char **cert_info_kpn(X509 *x509) {
int i,j;
static char *entries[CERT_INFO_SIZE];
STACK_OF(GENERAL_NAME) *gens;
GENERAL_NAME *name;
ASN1_OBJECT *krb5PrincipalName;
printf(Trying to find a Kerberos Principal Name in 
 certificate);
gens = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, NULL);
krb5PrincipalName = OBJ_txt2obj(1.3.6.1.5.2.2, 1);
if (!gens) {
printf(No alternate name extensions);
return NULL; /* no alternate names */
}
if (!krb5PrincipalName) {
printf(Cannot map KPN object);
return NULL;
}
for (i=0,j=0; (i  sk_GENERAL_NAME_num(gens))  
 (jCERT_INFO_MAX_ENTRIES); i++) {
name = sk_GENERAL_NAME_value(gens, i);
if ( name  name-type==GEN_OTHERNAME ) {  /* test for 
 UPN */
if (OBJ_cmp(name-d.otherName-type_id, 
 krb5PrincipalName)) continue; /* object is not a UPN */
else {
/* NOTE:
from PKINIT RFC, I deduce that stored format for 
 kerberos
Principal Name is ASN1_STRING, but not sure at 100%
Any help will be granted
*/
unsigned char *txt;
ASN1_TYPE *val = name-d.otherName-value;
ASN1_STRING *str= val-value.asn1_string;
printf(Found Kerberos Principal Name );


unsigned char * p = str-data;
KDC_PRINCNAME *pn = d2i_KDC_PRINCNAME(NULL, p, 
str-length);
KRB5_PRINCNAME *princname = pn-princname;
printf(Realm '%*s'\nNAMETYPE: %ld\n,
pn-realm-length, pn-realm-data,
ASN1_INTEGER_get(princname-nametype));
for (j=0; 
jsk_ASN1_GENERALSTRING_num(princname-namestring); j++) {
ASN1_GENERALSTRING *gs = 
sk_ASN1_GENERALSTRING_value(princname-namestring,j);
printf([%i] %*s\n, j, gs-length, gs-data);
}



Cheers

Christian
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Problem with rsa_keygen

2010-09-22 Thread Nacho Álvarez
Hello everybody

Several months ago I developed an OpenSSL PKCS#11 engine for Windows XP and
it worked ok (it was compiled with MinGW).
Now I'm trying to compile it on Linux (Debian 5 with GCC 4.3.1) but I have
the next problem:

In the overwritten function *rsa_keygen* (whose signature is *int rsa_keygen
(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)*) always when the function
ends (after the return instrucction) System reports me *Segmentation Fault*.
What I do is:

   1. I generate the RSA key with PKCS#11.
   2. I get the public part of the key from the device.
   3. I store this information in the *rsa* variable (I don't do memory
   allocation or *RSA_new ()* invoke, I supose rsa variable is initialized).
   If I do memory allocation or I invoke *RSA_new ()* I get the same error.
   4. Finally I return 1 if the process ends ok and -1 in case of error
   (PKCS#11 error).

And when the function ends I get Segmentation fault and I don't know why.

The OpenSSL version is 1.0.0a (I compiled it from source code).

Thanks.


Install/Add static engine

2010-09-22 Thread Niklas Eklund
Hi.

I have written an engine and have openssl installed (Ubuntu 10.04). Now I'd
like to compile and install my engine as a static engine that can be used by
openssl.

What are the commands for this and what steps shall I take? Thanks.


Re: Confusion about subject alternative names - resolved

2010-09-22 Thread Patrick Patterson
Hi there:

Yes - the right way is to correctly configure the extensions in the openssl.cnf 
used on the CA, and have the SAN and Subject NOT be used out of the request, 
but be input from the CA.

If you need to see how this might be done, we've got a tutorial at:

http://www.carillon.ca/library/openssl_testca_howto_1.3.pdf

Even within a corporate environment, you can have problems with malicious 
insiders, and if they can trick someone outside of your organisation to trust 
you as a CA, then you could get in all manner of trouble if you trust user 
input.

(I presume you have at least a rudimentary way to tie a given private key to a 
Subscriber? - that is what is important, not the contents of the CSR)

Best Regards,

Patrick.

On 2010-09-20, at 2:12 PM, Gaiseric Vandal wrote:

 I am  mostly using openssl to sign certificates for corporate servers for 
 corporate users only.   So I am the only one using it to issue certificates.  
 As much as possible I want all certificates to have a common CA-  that way 
 corporate end users only need to manually install the public cert for the CA 
 itself.  I can leave the copy_extensions = copy option disabled by default 
 and just enable when specifically needed.
 
 
 However, if there is another way to do this then I would like to know.  The 
 only other option I can see if to configure a Microsoft CA or some other CA 
 that does not use openssl.
 
 -Thanks
 
 
 
 On 09/20/2010 12:07 PM, Patrick Patterson wrote:
 Hey there:
 
 It should be noted that this is an EXCEEDINGLY BAD thing to do, since it more
 or less removes any control that the CA has over the certificates that it
 issues, and unless the Registration Authority is VERY careful about examining
 all of the requests in detail, all manner of evil and bad things could 
 happen,
 including:
 
 - The CA could inadvertantly create a SubCA, if the request has
 basicConstraints: CA:TRUE and the appropriate keyUsage fields set.
 
 - The CA could sign for SAN values that it has not proofed.
 
 - The CA could sign for keyUsage and ExtendedKeyUsage values which it may not
 grant or wish to grant the Subscriber Certificate
 
 - The CA could sign asserting that the end-entity certificate conforms to a
 policy that it does not (leading to potentially serious legal implications 
 for
 the CA including charges of fraud and misrepresentation).
 
 All that the attacker has to do with this option enabled is supply the CA 
 with
 an request with each or all of those extensions present and appropriately
 configured.
 
 All in all, unless this is a test CA that is clearly marked as non-
 trustworthy, then this is probably not at all what you want to do, and could
 have potentially serious implications not only at a technical level, but at a
 liability and organisational level.
 
 Best Regards,
 
 Patrick.
 
 On September 19, 2010 09:20:51 pm Gaiseric Vandal wrote:
 
 FYI, enabling the following line in openssl.cnf has resolved the problem.
 
 
 
 copy_extensions = copy
 
 
 
 
 
 
 
 From: Gaiseric Vandal [mailto:gaiseric.van...@gmail.com]
 Sent: Saturday, September 18, 2010 7:09 PM
 To: openssl-users@openssl.org
 Subject: RE: Confusion about subject alternative names
 
 
 
 Some additional info:
 
 
 
 My openssl.cnf file includes the following
 
 
 
 ---
 - ---
 
 policy  = policy_anything
 
 
 
 [ policy_anything ]
 
 countryName = optional
 
 stateOrProvinceName = optional
 
 localityName= optional
 
 organizationName= optional
 
 organizationalUnitName  = optional
 
 commonName  = supplied
 
 emailAddress= optional
 
 subjectAltName  = optional
 
 ..
 
 
 
 # req_extensions = v3_req # The extensions to add to a certificate request
 
 
 
 [ req_distinguished_name ]..
 
 subjectAltName  = Subject Alternate Name
 
 subjectAltName_default  = www.foo.com
 
 
 
 ---
 - ---
 
 
 
 
 
 Openssl is configured as a CA.
 
 
 
 I had added the entries for subjectAltName.I do get prompted for this
 when creating a certificate signing request (CSR.).
 
 
 
 When I submit a CSR  created by MS Exchange shell,the policy can  NOT
 include subjectAltName = required- So  clearly MS Exchange is not
 using the same structure for this as openssl.
 
 
 
 
 
 I am pretty sure I have the correct syntax for subjectAltName in
 openssl.cnf.
 
 
 
 If I try adding a field in for planet it is just ignored.So it seams
 clear that openssl is treating subjectAltName as a valid entry.
 
 
 
 
 
 The default openssl.cnf included
 
 
 
 ---
 - ---
 
 [ usr_cert ]
 
 ..
 
 # 

Re: Problem with rsa_keygen

2010-09-22 Thread Christian Hohnstaedt
On Wed, Sep 22, 2010 at 03:41:30PM +0200, Nacho ?lvarez wrote:
 Hello everybody
 
 Several months ago I developed an OpenSSL PKCS#11 engine for Windows XP and
 it worked ok (it was compiled with MinGW).
 Now I'm trying to compile it on Linux (Debian 5 with GCC 4.3.1) but I have
 the next problem:
 
 In the overwritten function *rsa_keygen* (whose signature is *int rsa_keygen
 (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)*) always when the function
 ends (after the return instrucction) System reports me *Segmentation Fault*.

You overwrote you return address on the stack most probably by
accessing a locally declared array out of bounds.

Cheers

Christian
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


REGD : openssl vulnerability CVE-2010-2939 : double in ssl3_get_key_exchange

2010-09-22 Thread Aparajita Sood (apsood)
Hi OpenSSL Folks,
 
I'm evaluating our product for this vulnerability.
http://www.mail-archive.com/openssl-...@openssl.org/msg28049.html
http://www.mail-archive.com/openssl-...@openssl.org/msg28049.html 
 
I have a few questions :
 
1. The vulnerability says
 You are right : there is a double free bug in the function 
 *ssl3_get_key_exchange* which leads to crash if an error occurs.
 The bug is in line 1510 of s3_clnt.c where we forget to set the
 variable bn_ctx to NULL after freeing it and this leads to the
 double free error when BN_CTX_free is called a second time on line
 1650. 
 

In 0.9.7d and prior I see no reference to bn_ctx or BN_CTX_free
 
QUESTION:  Since I do not see references to bn_ctx or BN_CTX_free in
0.9.7d can I assume that the vulnerability does not exist on that
version?
 
2. The link says  OpenSSL versions 1.0.0a, 0.9.8, 0.9.7,
 and possibly other versions, are affected when Elliptic curve
 Diffie-Hellman (ECDH) is enabled
 
QUESTION: Since I don't see BN_CTX_free being used in 0.9.7d and  prior,
do they mean that 7e, f , g have these definitions ?

3. I checked in the opensslconf.h file for #define OPENSSL_NO_ECDH to
check if ECDH is enabled or not 

QUESTION: is this the correct way to find if ecdh is enabled or not?
 
Would be great if I can get a response to these 
 
thanks
aparajita



Subject alternative name problem

2010-09-22 Thread Vinay Kumar L

Hi all,

I have to generate a KDC certificate containing Subject alternative name 
extension using openssl which includes the following details:

**
The KDC's  X.509 certificate MUST contain  name of the realm for that 
KDC and the principal name of the KDC (defined in RFC 1510bis) as the 
SubjectAltName version 3 extension. Below is
the definition of this version 3 extension, as specified by the X.509 
standard:

   subjectAltName EXTENSION ::= {
   SYNTAX GeneralNames
   IDENTIFIED BY id-ce-subjectAltName
   }
   GeneralNames ::= SEQUENCE SIZE(1..MAX) OF GeneralName

   GeneralName ::= CHOICE {
otherName  [0] OtherName,
...
   }
   OtherName ::= SEQUENCE {
type-idOBJECT IDENTIFIER,
value  [0] EXPLICIT ANY DEFINED BY type-id
   }
For the purpose of specifying a Kerberos principal name, the value
in OtherName MUST be a KerberosName, defined as follows:
   KerberosName ::= SEQUENCE {
realm  [0] Realm,
principalName  [1] PrincipalName
   }
This specific syntax is identified within subjectAltName by setting
the type-id in OtherName to krb5PrincipalName, where (from the
Kerberos specification) we have
   krb5 OBJECT IDENTIFIER ::= { iso (1)
org (3)
dod (6)
internet (1)
security (5)
kerberosv5 (2) }
   krb5PrincipalName OBJECT IDENTIFIER ::= { krb5 2 }
*
Please suggest SAN details that must be included in openssl.cnf for 
generating KDC certificate containing above mentioned details as a part 
of Subject Alternative Extension in kdc certificate.
I have generated KDC certificate by including following lines in 
openssl.cnf:

# Add id-pkinit-san (pkinit subjectAlternativeName)

subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:kdc_princ_name

[kdc_princ_name]
realm = EXP:0, GeneralString:${ENV::REALM}
principal_name = EXP:1, SEQUENCE:kdc_principal_seq

[kdc_principal_seq]
name_type = EXP:0, INTEGER:1
name_string = EXP:1, SEQUENCE:kdc_principals

[kdc_principals]
princ1 = GeneralString:krbtgt

Is is enough to include the above lines in opensssl.cnf while generating kdc 
certificate
to add Subject Alternative Extension which satisfies the requirements mentioned 
in the beginning?
Please guide me.

Regards,
Vinay


princ2 = GeneralString:${ENV::REALM}






Understanding: EncryptedPrivateKeyInfo

2010-09-22 Thread muellste
Hello,

I try to understand the encryption of a private rsa key. It was generated
with

 openssl genpkey -aes-256-cbc -algorithm rsa -out mykey.enc
-pkeyopt rsa_keygen_bits:2048

(pw: 'admin', file attached)

according to pkcs#8 the result is

EncryptedPrivateKeyInfo ::= SEQUENCE {
encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
encryptedData EncryptedData
}

parsing through 'encryptionAlgorithm' i got

 openssl asn1parse - in mykey.enc -strparse 4
0: d=0 hl=2 l=73 cons : SEQUENCE
2: d=1 hl=2 l=9 prim : OBJECT: PBES2
13: d=1 hl=2 l=60 cons : SEQUENCE
15: d=2 hl=2 l=27 cons : SEQUENCE
17: d=3 hl=2 l=9 prim :OBJECT: PBKDF2
28: d=3 hl=2 l=14 cons :SEQUENCE
30: d=4 hl=2 l=8 prim :OCTET STRING
[ HEX DUMP ]:7C4B1587B12A7705
40: d=4 hl=2 l=2 prim :INTEGER: 0800
44: d=2 hl=2 l= 29 cons :SEQUENCE
46: d=3 hl=2 l=9 prim :OBJECT :aes-256-cbc
57: d=3 hl=2 l=16 prim :OCTET STRING
[ HEX DUMP ]: 4850BA5F76BA9CD5574F0121D8C0C657.

as i understood the rare documenation, offset 30 is the salt for PBKDF2
and offset 57 is the IV for aes.

as result of PKCS5_PBKDF2_HMAC_SHA1 feeded with the salt from above,
pw:'admin' and ic:2048 (offset 40 above) i got:

K  = dc55f54889fe64153fb1b181e89ec5c08a864ef5f777d6aa1d0be9ff82dd8b3a
iv = 11be3aafd0768fd9fdbc7880936ad2c4

decryption with this key (and any of those ivs) fails.

How can i reproduce the data in offset 57? if its really an iv why is it
written explicitly if it could be calculated a result of PBKDF2?

Does anyone have some hints?

  thanks a lot..  stephan

mykey.enc
Description: Binary data


Re: Confusion about subject alternative names - resolved

2010-09-22 Thread Patrick Patterson
Hi there:

Yes - the right way is to correctly configure the extensions on the CA, and 
have the SAN and Subject NOT be used out of the request, but be input from the 
CA.

If you need to see how this might be done, we've got a tutorial at:

http://www.carillon.ca/library/openssl_testca_howto_1.3.pdf

Even within a corporate environment, you can have problems with malicious 
insiders, and if they can trick someone outside of your organisation to trust 
you as a CA, then you could get in all manner of trouble if you trust user 
input.

(I presume you have at least a rudimentary way to tie a given private key to a 
Subscriber? - that is what is important, not the contents of the CSR)

Best Regards,

Patrick.

On 2010-09-20, at 2:12 PM, Gaiseric Vandal wrote:

 I am  mostly using openssl to sign certificates for corporate servers for 
 corporate users only.   So I am the only one using it to issue certificates.  
 As much as possible I want all certificates to have a common CA-  that way 
 corporate end users only need to manually install the public cert for the CA 
 itself.  I can leave the copy_extensions = copy option disabled by default 
 and just enable when specifically needed.
 
 
 However, if there is another way to do this then I would like to know.  The 
 only other option I can see if to configure a Microsoft CA or some other CA 
 that does not use openssl.
 
 -Thanks
 
 
 
 On 09/20/2010 12:07 PM, Patrick Patterson wrote:
 Hey there:
 
 It should be noted that this is an EXCEEDINGLY BAD thing to do, since it more
 or less removes any control that the CA has over the certificates that it
 issues, and unless the Registration Authority is VERY careful about examining
 all of the requests in detail, all manner of evil and bad things could 
 happen,
 including:
 
 - The CA could inadvertantly create a SubCA, if the request has
 basicConstraints: CA:TRUE and the appropriate keyUsage fields set.
 
 - The CA could sign for SAN values that it has not proofed.
 
 - The CA could sign for keyUsage and ExtendedKeyUsage values which it may not
 grant or wish to grant the Subscriber Certificate
 
 - The CA could sign asserting that the end-entity certificate conforms to a
 policy that it does not (leading to potentially serious legal implications 
 for
 the CA including charges of fraud and misrepresentation).
 
 All that the attacker has to do with this option enabled is supply the CA 
 with
 an request with each or all of those extensions present and appropriately
 configured.
 
 All in all, unless this is a test CA that is clearly marked as non-
 trustworthy, then this is probably not at all what you want to do, and could
 have potentially serious implications not only at a technical level, but at a
 liability and organisational level.
 
 Best Regards,
 
 Patrick.
 
 On September 19, 2010 09:20:51 pm Gaiseric Vandal wrote:
   
 FYI, enabling the following line in openssl.cnf has resolved the problem.
 
 
 
 copy_extensions = copy
 
 
 
 
 
 
 
 From: Gaiseric Vandal [mailto:gaiseric.van...@gmail.com]
 Sent: Saturday, September 18, 2010 7:09 PM
 To: openssl-users@openssl.org
 Subject: RE: Confusion about subject alternative names
 
 
 
 Some additional info:
 
 
 
 My openssl.cnf file includes the following
 
 
 
 ---
 - ---
 
 policy  = policy_anything
 
 
 
 [ policy_anything ]
 
 countryName = optional
 
 stateOrProvinceName = optional
 
 localityName= optional
 
 organizationName= optional
 
 organizationalUnitName  = optional
 
 commonName  = supplied
 
 emailAddress= optional
 
 subjectAltName  = optional
 
 ..
 
 
 
 # req_extensions = v3_req # The extensions to add to a certificate request
 
 
 
 [ req_distinguished_name ]..
 
 subjectAltName  = Subject Alternate Name
 
 subjectAltName_default  = www.foo.com
 
 
 
 ---
 - ---
 
 
 
 
 
 Openssl is configured as a CA.
 
 
 
 I had added the entries for subjectAltName.I do get prompted for this
 when creating a certificate signing request (CSR.).
 
 
 
 When I submit a CSR  created by MS Exchange shell,the policy can  NOT
 include subjectAltName = required- So  clearly MS Exchange is not
 using the same structure for this as openssl.
 
 
 
 
 
 I am pretty sure I have the correct syntax for subjectAltName in
 openssl.cnf.
 
 
 
 If I try adding a field in for planet it is just ignored.So it seams
 clear that openssl is treating subjectAltName as a valid entry.
 
 
 
 
 
 The default openssl.cnf included
 
 
 
 ---
 - ---
 
 [ usr_cert ]
 
 ..
 
 # This stuff is for 

Re: Subject alternative name problem

2010-09-22 Thread Vinay Kumar L

Vinay Kumar L wrote:

Hi all,

I have to generate a KDC certificate containing Subject alternative 
name extension using openssl which includes the following details:

**
The KDC's  X.509 certificate MUST contain  name of the realm for that 
KDC and the principal name of the KDC (defined in RFC 1510bis) as the 
SubjectAltName version 3 extension. Below is
the definition of this version 3 extension, as specified by the X.509 
standard:

subjectAltName EXTENSION ::= {
SYNTAX GeneralNames
IDENTIFIED BY id-ce-subjectAltName
}
GeneralNames ::= SEQUENCE SIZE(1..MAX) OF GeneralName

GeneralName ::= CHOICE {
 otherName  [0] OtherName,
 ...
}
OtherName ::= SEQUENCE {
 type-idOBJECT IDENTIFIER,
 value  [0] EXPLICIT ANY DEFINED BY type-id
}
For the purpose of specifying a Kerberos principal name, the value
in OtherName MUST be a KerberosName, defined as follows:
KerberosName ::= SEQUENCE {
 realm  [0] Realm,
 principalName  [1] PrincipalName
}
This specific syntax is identified within subjectAltName by setting
the type-id in OtherName to krb5PrincipalName, where (from the
Kerberos specification) we have
krb5 OBJECT IDENTIFIER ::= { iso (1)
 org (3)
 dod (6)
 internet (1)
 security (5)
 kerberosv5 (2) }
krb5PrincipalName OBJECT IDENTIFIER ::= { krb5 2 }
*
Please suggest SAN details that must be included in openssl.cnf for 
generating KDC certificate containing above mentioned details as a 
part of Subject Alternative Extension in kdc certificate.
I have generated KDC certificate by including following lines in 
openssl.cnf:

# Add id-pkinit-san (pkinit subjectAlternativeName)
subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:kdc_princ_name

[kdc_princ_name]
realm = EXP:0, GeneralString:${ENV::REALM}
principal_name = EXP:1, SEQUENCE:kdc_principal_seq

[kdc_principal_seq]
name_type = EXP:0, INTEGER:1
name_string = EXP:1, SEQUENCE:kdc_principals

[kdc_principals]
princ1 = GeneralString:krbtgt

Is is enough to include the above lines in opensssl.cnf while generating kdc 
certificate
to add Subject Alternative Extension which satisfies the requirements mentioned 
in the beginning?
Please guide me.

Regards,
Vinay


princ2 = GeneralString:${ENV::REALM}







Understanding: EncryptedPrivateKeyInfo

2010-09-22 Thread muellste
Hello,

I try to understand the encryption of a private rsa key. It was generated
with

 openssl genpkey -aes-256-cbc -algorithm rsa -out mykey.enc
-pkeyopt rsa_keygen_bits:2048

(pw: 'admin', file attached)

according to pkcs#8 the result is

EncryptedPrivateKeyInfo ::= SEQUENCE {
encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
encryptedData EncryptedData
}

parsing through 'encryptionAlgorithm' i got

 openssl asn1parse - in mykey.enc -strparse 4
0: d=0 hl=2 l=73 cons : SEQUENCE
2: d=1 hl=2 l=9 prim : OBJECT: PBES2
13: d=1 hl=2 l=60 cons : SEQUENCE
15: d=2 hl=2 l=27 cons : SEQUENCE
17: d=3 hl=2 l=9 prim :OBJECT: PBKDF2
28: d=3 hl=2 l=14 cons :SEQUENCE
30: d=4 hl=2 l=8 prim :OCTET STRING
[ HEX DUMP ]:7C4B1587B12A7705
40: d=4 hl=2 l=2 prim :INTEGER: 0800
44: d=2 hl=2 l= 29 cons :SEQUENCE
46: d=3 hl=2 l=9 prim :OBJECT :aes-256-cbc
57: d=3 hl=2 l=16 prim :OCTET STRING
[ HEX DUMP ]: 4850BA5F76BA9CD5574F0121D8C0C657.

as i understood the rare documenation, offset 30 is the salt for PBKDF2
and offset 57 is the IV for aes.

as result of PKCS5_PBKDF2_HMAC_SHA1 feeded with the salt from above,
pw:'admin' and ic:2048 (offset 40 above) i got:

K  = dc55f54889fe64153fb1b181e89ec5c08a864ef5f777d6aa1d0be9ff82dd8b3a iv =
11be3aafd0768fd9fdbc7880936ad2c4

decryption with this key (and any of those ivs) fails.

How can i reproduce the data in offset 57? if its really an iv why is it
written explicitly if it could be calculated a result of PBKDF2?

Does anyone have some hints?

  thanks a lot..  stephan


mykey.enc
Description: Binary data


LNK4078 and LNK4210 linking with x64 static libs

2010-09-22 Thread perfry

Hi,

I've built 1.0.0a on Windows with VS2005, using nt.mak to get static 
libraries.
With x64 I get warnings when linking applications, both openssl.exe and 
test programs like sha1test.exe. A snippet of output from nmake -f 
ms\nt.mak:
   link /nologo /subsystem:console /opt:ref /debug 
/out:out32\openssl.exe @C:\DOCUME~1\FRYKEN~1\LOCALS~1\Temp\nm3B3.tmp
LIBCMT.lib(crt0init.obj) : warning LNK4254: section '.CRT' (6020) 
merged into '.rdata' (4040) with different attributes



And when linking our own application on x64/Release platform:
   libeay32.lib(x86_64cpuid.obj) : warning LNK4078: multiple '.CRT' 
sections found with different attributes (60500020)
   libeay32.lib(x86_64cpuid.obj) : warning LNK4210: .CRT section 
exists; there may be unhandled static initializers or terminators



The linker command can be deduced from the following:
   Creating temporary file 
c:\utv\ccbas4\ccbase\x64\Release\RSP132444832.rsp with contents

   [
   /OUT:../deploy/execs/x64/Release/etnode.exe /INCREMENTAL:NO 
/MANIFEST /MANIFESTFILE:x64/Release\etnode.exe.intermediate.manifest 
/DELAYLOAD:oci.dll /DEBUG 
/PDB:../deploy/execs/x64/Release/etnode.pdb /SUBSYSTEM:CONSOLE /LTCG 
psapi.lib odbc32.lib odbccp32.lib WS2_32.LIB ADVAPI32.LIB GDI32.LIB 
USER32.LIB dbghelp.lib 
../snibu/logging-log4cxx/msvc/lib/x64/Release/log4cxxs.lib 
../snibu/openssl-1.0.0a/x64/Release/lib/ssleay32.lib 
../snibu/openssl-1.0.0a/x64/Release/lib/libeay32.lib 
../snibu/oracle/x64/instantclient_10_2/sdk/lib/msvc/oci.lib 
../snibu/zlib/msvc/lib/x64/Release/zlibstat.lib kernel32.lib user32.lib 
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib


   .\x64\Release\CCcServApp.obj
   ...
   .\x64\Release\Bas4Bridge.obj
   ]
   Creating command line link.exe 
@c:\utv\ccbas4\ccbase\x64\Release\RSP132444832.rsp /NOLOGO 
/ERRORREPORT:PROMPT



I've done the following to build openssl:
   cd /d C:\utv\snibu\openssl\x64\release\openssl-1.0.0a
   call C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat 
x86_amd64

   perl Configure VC-WIN64A --prefix=c:\appl\openssl-1.0.0a\x64\release
   ms\do_win64a.bat
   nmake -f ms\nt.mak
   nmake -f ms\nt.mak install

And the file x86_64cpuid.asm mentioned in the warnings starts with the 
following:

   defaultrel
   EXTERNOPENSSL_cpuid_setup
   section.CRT$XCU
   ALIGN8
   DQOPENSSL_cpuid_setup

   section.text code align=64
...


Could somebody help me solve this warning, it seems to me that 
OPENSSL_cpuid_setup will not be executed.



Best regards,
Per Frykenvall
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: EDIT FIELDS ON CSR

2010-09-22 Thread kummers

Hi,

Thank you very much for your answer, so is no way to edit the filed of a csr
not? But please could your explainme more detailed how can I bind the 
public key or just do your recomendation?

I really appreciate your help.



Patrick Patterson-3 wrote:
 
 On September 11, 2010 10:58:44 am kummers wrote:
 Please, help me:
 
 
 How can I edit a CSR, i neew to chane the filds, for axample. edit the
 common name, I've been looking but have not found anything in the forum
 
 You cannot edit a CSR - it is a signed structure - why don't you just re-
 generate it with the correct values?
 
 Also - there is absolutely NOTHING that says that you have to keep the 
 information in a CSR when you generate the X.509 certificate - so if you
 need 
 to change the Subject DN so that when you generate the Certificate get a 
 different value, just tell OpenSSL (or whatever CA software you are using)
 to 
 do that.
 
 (of course, the caveat with the above is that you need a good way to bind
 the 
 public key in the PKCS#10 or SPKAC structure with the subscriber named in
 the 
 Subject of the X.509, but you weren't just trusting a self asserted value
 in a 
 CSR to prove that, were you? :)
 
 Have fun!
 
 -- 
 Patrick Patterson
 President and Chief PKI Architect,
 Carillon Information Security Inc.
 http://www.carillon.ca
 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing Listopenssl-users@openssl.org
 Automated List Manager   majord...@openssl.org
 
 

-- 
View this message in context: 
http://old.nabble.com/EDIT-FIELDS-ON-CSR-tp29673141p29775548.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: LNK4078 and LNK4210 linking with x64 static libs

2010-09-22 Thread Jack Zhang
I had got the same problem. I just simply deleted that section
  EXTERNOPENSSL_cpuid_setup
  section.CRT$XCU
  ALIGN8
  DQOPENSSL_cpuid_setup

  section.text code align=64

from the asm file because the extern OpenSSL_cpuid_setup is never
referenced.

Good luck

On Tue, Sep 21, 2010 at 9:57 AM, perfry 
per.frykenv...@naturskyddsforeningen.se wrote:

 Hi,

 I've built 1.0.0a on Windows with VS2005, using nt.mak to get static
 libraries.
 With x64 I get warnings when linking applications, both openssl.exe and
 test programs like sha1test.exe. A snippet of output from nmake -f
 ms\nt.mak:
   link /nologo /subsystem:console /opt:ref /debug
 /out:out32\openssl.exe @C:\DOCUME~1\FRYKEN~1\LOCALS~1\Temp\nm3B3.tmp
 LIBCMT.lib(crt0init.obj) : warning LNK4254: section '.CRT' (6020)
 merged into '.rdata' (4040) with different attributes


 And when linking our own application on x64/Release platform:
   libeay32.lib(x86_64cpuid.obj) : warning LNK4078: multiple '.CRT' sections
 found with different attributes (60500020)
   libeay32.lib(x86_64cpuid.obj) : warning LNK4210: .CRT section exists;
 there may be unhandled static initializers or terminators


 The linker command can be deduced from the following:
   Creating temporary file
 c:\utv\ccbas4\ccbase\x64\Release\RSP132444832.rsp with contents
   [
   /OUT:../deploy/execs/x64/Release/etnode.exe /INCREMENTAL:NO /MANIFEST
 /MANIFESTFILE:x64/Release\etnode.exe.intermediate.manifest
 /DELAYLOAD:oci.dll /DEBUG /PDB:../deploy/execs/x64/Release/etnode.pdb
 /SUBSYSTEM:CONSOLE /LTCG psapi.lib odbc32.lib odbccp32.lib WS2_32.LIB
 ADVAPI32.LIB GDI32.LIB USER32.LIB dbghelp.lib
 ../snibu/logging-log4cxx/msvc/lib/x64/Release/log4cxxs.lib
 ../snibu/openssl-1.0.0a/x64/Release/lib/ssleay32.lib
 ../snibu/openssl-1.0.0a/x64/Release/lib/libeay32.lib
 ../snibu/oracle/x64/instantclient_10_2/sdk/lib/msvc/oci.lib
 ../snibu/zlib/msvc/lib/x64/Release/zlibstat.lib kernel32.lib user32.lib
 gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib

   .\x64\Release\CCcServApp.obj
   ...
   .\x64\Release\Bas4Bridge.obj
   ]
   Creating command line link.exe
 @c:\utv\ccbas4\ccbase\x64\Release\RSP132444832.rsp /NOLOGO
 /ERRORREPORT:PROMPT


 I've done the following to build openssl:
   cd /d C:\utv\snibu\openssl\x64\release\openssl-1.0.0a
   call C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat
 x86_amd64
   perl Configure VC-WIN64A --prefix=c:\appl\openssl-1.0.0a\x64\release
   ms\do_win64a.bat
   nmake -f ms\nt.mak
   nmake -f ms\nt.mak install

 And the file x86_64cpuid.asm mentioned in the warnings starts with the
 following:
   defaultrel
   EXTERNOPENSSL_cpuid_setup
   section.CRT$XCU
   ALIGN8
   DQOPENSSL_cpuid_setup

   section.text code align=64
 ...


 Could somebody help me solve this warning, it seems to me that
 OPENSSL_cpuid_setup will not be executed.


 Best regards,
 Per Frykenvall
 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing Listopenssl-users@openssl.org
 Automated List Manager   majord...@openssl.org



Self-signed CA problem for internal web application

2010-09-22 Thread Chris Rider




We have a client/server architecture based product that needs to allow
SSL communication between our server (CentOS) and various clients' web
browsers (and additionally, other devices, but that's beyond the scope
of this post).

We've been able to get SSL working in both of two different ways
(self-signed certificate  self-signed CA with certificates signed
by that) -- so that is not the issue. Rather, our whole issue is that
we don't want the end-users to confronted with a big scary browser
message that says something akin to "There's a Problem With Security! /
Allow Exception, etc." If they must install a certificate or two, that
would be acceptable, though. So I thought that creating my own CA to
sign certificates with would be a solution apparently not. I'm now
getting browser messages that say the certificate's issuer is not
trusted!!! Very frustrating.

So, as I said, I've created my own CA (using this link as a guide:
http://www.g-loaded.eu/2005/11/10/be-your-own-ca/ ), and can sign my
own certificates without problem. I then install the root certificate,
followed by a server certificate signed by that CA. And, while I can
click "allow exception" in the browser to make it all work, that is not
the desired way. We just want to be able to have the end-user install a
trusted root certificate and everything just work from there. Testing
in IE and FireFox nets the same big scary warning message, no matter
what combination of fields I use in the CSR, etc.

We really don't want to go with a third party CA like VeriSign, for
example -- not so much because of the cost, but we just don't want to
deal with updating countless remote installations of our product
whenever the certificate expires. Not to mention the support that would
be associated with doing that! The other issue is that some/most of
these installations do not have outside internet connectivity with
which to query the CA's (for CRL's, or whatever). We really need to
manage our own certificates, all in all but without these warning
messages.

Is it possible?
If so, what am I missing?

-- 

Chris Rider,
Systems Architect

MessageNet Systems
chris.ri...@messagenetsystems.com




__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Self-signed CA problem for internal web application

2010-09-22 Thread Chris Rider
We have a client/server architecture based product that needs to allow 
SSL communication between our server (CentOS) and various clients' web 
browsers (and additionally, other devices, but that's beyond the scope 
of this post).


We've been able to get SSL working in both of two different ways 
(self-signed certificate  self-signed CA with certificates signed by 
that) -- so that is not the issue. Rather, our whole issue is that we 
don't want the end-users to confronted with a big scary browser message 
that says something akin to There's a Problem With Security! / Allow 
Exception, etc. If they must install a certificate or two, that would 
be acceptable, though. So I thought that creating my own CA to sign 
certificates with would be a solution apparently not. I'm now 
getting browser messages that say the certificate's issuer is not 
trusted!!! Very frustrating.


So, as I said, I've created my own CA (using this link as a guide: 
http://www.g-loaded.eu/2005/11/10/be-your-own-ca/ ), and can sign my own 
certificates without problem. I then install the root certificate, 
followed by a server certificate signed by that CA. And, while I can 
click allow exception in the browser to make it all work, that is not 
the desired way. We just want to be able to have the end-user install a 
trusted root certificate and everything just work from there. Testing in 
IE and FireFox nets the same big scary warning message, no matter what 
combination of fields I use in the CSR, etc.


We really don't want to go with a third party CA like VeriSign, for 
example -- not so much because of the cost, but we just don't want to 
deal with updating countless remote installations of our product 
whenever the certificate expires. Not to mention the support that would 
be associated with doing that! The other issue is that some/most of 
these installations do not have outside internet connectivity with which 
to query the CA's (for CRL's, or whatever). We really need to manage our 
own certificates, all in all but without these warning messages.


Is it possible?
If so, what am I missing?

--
Chris Rider,
Systems Architect
MessageNet Systems
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Self-signed CA problem for internal web application

2010-09-22 Thread Hugo Garza
Hi Chris, how are you installing the root CA on the client machines?

In windows once you double click the root certificate you get a message
dialog box and click the install certificate button. On the following screen
press next and on the next screen tell it to install the certificate to the
Trusted Root Certificate Authorities, hit next then finish. You should get a
Windows dialog warning saying that you are adding a root certificate, and
you just say yes.

Now the other possible problem is that on the server certificate that you
created you aren't including the Authority Information Access (AIA) field.
This is crucial so that your customers only have to install the root CA
and implicitly trust any certificates signed by the root.

On Wed, Sep 22, 2010 at 2:29 PM, Chris Rider 
chris.ri...@messagenetsystems.com wrote:

 We have a client/server architecture based product that needs to allow SSL
 communication between our server (CentOS) and various clients' web browsers
 (and additionally, other devices, but that's beyond the scope of this post).

 We've been able to get SSL working in both of two different ways
 (self-signed certificate  self-signed CA with certificates signed by that)
 -- so that is not the issue. Rather, our whole issue is that we don't want
 the end-users to confronted with a big scary browser message that says
 something akin to There's a Problem With Security! / Allow Exception, etc.
 If they must install a certificate or two, that would be acceptable, though.
 So I thought that creating my own CA to sign certificates with would be a
 solution apparently not. I'm now getting browser messages that say the
 certificate's issuer is not trusted!!! Very frustrating.

 So, as I said, I've created my own CA (using this link as a guide:
 http://www.g-loaded.eu/2005/11/10/be-your-own-ca/ ), and can sign my own
 certificates without problem. I then install the root certificate, followed
 by a server certificate signed by that CA. And, while I can click allow
 exception in the browser to make it all work, that is not the desired way.
 We just want to be able to have the end-user install a trusted root
 certificate and everything just work from there. Testing in IE and FireFox
 nets the same big scary warning message, no matter what combination of
 fields I use in the CSR, etc.

 We really don't want to go with a third party CA like VeriSign, for example
 -- not so much because of the cost, but we just don't want to deal with
 updating countless remote installations of our product whenever the
 certificate expires. Not to mention the support that would be associated
 with doing that! The other issue is that some/most of these installations do
 not have outside internet connectivity with which to query the CA's (for
 CRL's, or whatever). We really need to manage our own certificates, all in
 all but without these warning messages.

 Is it possible?
 If so, what am I missing?

 --
 Chris Rider,
 Systems Architect
 MessageNet Systems
 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing Listopenssl-users@openssl.org
 Automated List Manager   majord...@openssl.org



Re: Self-signed CA problem for internal web application

2010-09-22 Thread Patrick Patterson
Hi Chris:

Can you post the certificates in question? My guess is that you don't have the 
various extensions set according to the PKIX standards that the Browsers are 
expecting.

Thanks.

Patrick.
On 2010-09-22, at 2:57 PM, Chris Rider wrote:

 We have a client/server architecture based product that needs to allow SSL 
 communication between our server (CentOS) and various clients' web browsers 
 (and additionally, other devices, but that's beyond the scope of this post).
 
 We've been able to get SSL working in both of two different ways (self-signed 
 certificate  self-signed CA with certificates signed by that) -- so that is 
 not the issue. Rather, our whole issue is that we don't want the end-users to 
 confronted with a big scary browser message that says something akin to 
 There's a Problem With Security! / Allow Exception, etc. If they must 
 install a certificate or two, that would be acceptable, though. So I thought 
 that creating my own CA to sign certificates with would be a solution 
 apparently not. I'm now getting browser messages that say the certificate's 
 issuer is not trusted!!! Very frustrating.
 
 So, as I said, I've created my own CA (using this link as a guide: 
 http://www.g-loaded.eu/2005/11/10/be-your-own-ca/ ), and can sign my own 
 certificates without problem. I then install the root certificate, followed 
 by a server certificate signed by that CA. And, while I can click allow 
 exception in the browser to make it all work, that is not the desired way. 
 We just want to be able to have the end-user install a trusted root 
 certificate and everything just work from there. Testing in IE and FireFox 
 nets the same big scary warning message, no matter what combination of fields 
 I use in the CSR, etc.
 
 We really don't want to go with a third party CA like VeriSign, for example 
 -- not so much because of the cost, but we just don't want to deal with 
 updating countless remote installations of our product whenever the 
 certificate expires. Not to mention the support that would be associated with 
 doing that! The other issue is that some/most of these installations do not 
 have outside internet connectivity with which to query the CA's (for CRL's, 
 or whatever). We really need to manage our own certificates, all in all 
 but without these warning messages.
 
 Is it possible?
 If so, what am I missing?
 
 -- 
 Chris Rider,
 Systems Architect
 MessageNet Systems
 chris.ri...@messagenetsystems.com
 __ 
 OpenSSL Project http://www.openssl.org User Support Mailing List 
 openssl-users@openssl.org Automated List Manager majord...@openssl.org

---
Patrick Patterson
President and Chief PKI Architect
Carillon Information Security Inc.
http://www.carillon.ca

tel: +1 514 485 0789
mobile: +1 514 994 8699
fax: +1 450 424 9559





__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Self-signed CA problem for internal web application

2010-09-22 Thread Chris Rider
For now, I've just copied the CA's public .crt file to a public_html 
type directory and downloading on the client ~ from there, depending on 
whether I use FireFox or IE, I go into the respective certificates 
manager and import the one I downloaded. I've been very deliberate in 
making sure it actually gets installed under the root/trusted category, 
and not some other category.


I haven't investigated the AIA field... (didn't even know about it)

Would that be specified when creating the CA's keys? Is that best 
specified in my CA's cnf file somewhere?


Barring all else, it seems to me like the browser is hanging up on the 
fact that the CA's certificate is self-signed. (??)


-Chris


Hugo Garza wrote:

Hi Chris, how are you installing the root CA on the client machines?

In windows once you double click the root certificate you get a 
message dialog box and click the install certificate button. On the 
following screen press next and on the next screen tell it to install 
the certificate to the Trusted Root Certificate Authorities, hit next 
then finish. You should get a Windows dialog warning saying that you 
are adding a root certificate, and you just say yes.


Now the other possible problem is that on the server certificate that 
you created you aren't including the Authority Information Access 
(AIA) field. This is crucial so that your customers only have to 
install the root CA and implicitly trust any certificates signed by 
the root.


On Wed, Sep 22, 2010 at 2:29 PM, Chris Rider 
chris.ri...@messagenetsystems.com 
mailto:chris.ri...@messagenetsystems.com wrote:


We have a client/server architecture based product that needs to
allow SSL communication between our server (CentOS) and various
clients' web browsers (and additionally, other devices, but that's
beyond the scope of this post).

We've been able to get SSL working in both of two different ways
(self-signed certificate  self-signed CA with certificates signed
by that) -- so that is not the issue. Rather, our whole issue is
that we don't want the end-users to confronted with a big scary
browser message that says something akin to There's a Problem
With Security! / Allow Exception, etc. If they must install a
certificate or two, that would be acceptable, though. So I thought
that creating my own CA to sign certificates with would be a
solution apparently not. I'm now getting browser messages that
say the certificate's issuer is not trusted!!! Very frustrating.

So, as I said, I've created my own CA (using this link as a guide:
http://www.g-loaded.eu/2005/11/10/be-your-own-ca/ ), and can sign
my own certificates without problem. I then install the root
certificate, followed by a server certificate signed by that CA.
And, while I can click allow exception in the browser to make it
all work, that is not the desired way. We just want to be able to
have the end-user install a trusted root certificate and
everything just work from there. Testing in IE and FireFox nets
the same big scary warning message, no matter what combination of
fields I use in the CSR, etc.

We really don't want to go with a third party CA like VeriSign,
for example -- not so much because of the cost, but we just don't
want to deal with updating countless remote installations of our
product whenever the certificate expires. Not to mention the
support that would be associated with doing that! The other issue
is that some/most of these installations do not have outside
internet connectivity with which to query the CA's (for CRL's, or
whatever). We really need to manage our own certificates, all in
all but without these warning messages.

Is it possible?
If so, what am I missing?

-- 
Chris Rider,

Systems Architect
MessageNet Systems
__
OpenSSL Project http://www.openssl.org
User Support Mailing List  
 openssl-users@openssl.org mailto:openssl-users@openssl.org
Automated List Manager  
majord...@openssl.org mailto:majord...@openssl.org




__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Self-signed CA problem for internal web application

2010-09-22 Thread John R Pierce

 On 09/22/10 11:57 AM, Chris Rider wrote:
We have a client/server architecture based product that needs to allow 
SSL communication between our server (CentOS) and various clients' web 
browsers (and additionally, other devices, but that's beyond the scope 
of this post).


We've been able to get SSL working in both of two different ways 
(self-signed certificate  self-signed CA with certificates signed by 
that) -- so that is not the issue. Rather, our whole issue is that we 
don't want the end-users to confronted with a big scary browser 
message that says something akin to There's a Problem With Security! 
/ Allow Exception, etc. If they must install a certificate or two, 
that would be acceptable, though. So I thought that creating my own CA 
to sign certificates with would be a solution apparently not. I'm 
now getting browser messages that say the certificate's issuer is not 
trusted!!! Very frustrating.


take your selfsigned CA public certificate, name it something.cer, and 
place it on a web server, making sure the webserver understands that 
.cer is mime type application/x-x509-ca-cert


give your clients the link to that .CER ...  they have to accept it and 
add it to their trusted root certificate storage, the specifics of doing 
this vary by web browser (current versions of MSIE have made this harder 
than it should be)



once that .cer is installed in the browsers trusted root authorities, 
then anything signed by that CA will be accepted.



__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Confusion about subject alternative names - resolved

2010-09-22 Thread Gaiseric Vandal

Thanks for the link.

I still need the CA to load the SAN parameter from the request-  it 
looks like a lot of the defaults would be to copy the e-mail address 
into the SAN field.


I don't use openssl at this point to generate certs for users.  No one 
besides me uses openssl ca on this server anyway.   Of course, that 
doesn't stop anyone from using openssl on their own machine to create 
whatever keys and certs they want anyway-  I could create CA 
configuration for microsoft.com and use it to create send Secure 
e-mail from microsoft.


If I start dealing with user certificates then I would probably need a 
more full featured CA solution that allows web-based user requests and 
key escrow.I have started tinkering with the DogTag (opensource 
version of redhat cert server) but so far not sure if it supports the 
SAN extensions properly.  I may have to suck it up and just install the 
MS CA services to have something that plays nice with MS Exchange and 
other MS services.  I try to avoid MS Solutions because they tend to 
optimize standards.






On 09/22/2010 10:31 AM, Patrick Patterson wrote:

Hi there:

Yes - the right way is to correctly configure the extensions in the openssl.cnf 
used on the CA, and have the SAN and Subject NOT be used out of the request, 
but be input from the CA.

If you need to see how this might be done, we've got a tutorial at:

http://www.carillon.ca/library/openssl_testca_howto_1.3.pdf

Even within a corporate environment, you can have problems with malicious 
insiders, and if they can trick someone outside of your organisation to trust 
you as a CA, then you could get in all manner of trouble if you trust user 
input.

(I presume you have at least a rudimentary way to tie a given private key to a 
Subscriber? - that is what is important, not the contents of the CSR)

Best Regards,

Patrick.

On 2010-09-20, at 2:12 PM, Gaiseric Vandal wrote:

   

I am  mostly using openssl to sign certificates for corporate servers for corporate users 
only.   So I am the only one using it to issue certificates.  As much as possible I want 
all certificates to have a common CA-  that way corporate end users only need to manually 
install the public cert for the CA itself.  I can leave the copy_extensions = 
copy option disabled by default and just enable when specifically needed.


However, if there is another way to do this then I would like to know.  The 
only other option I can see if to configure a Microsoft CA or some other CA 
that does not use openssl.

-Thanks



On 09/20/2010 12:07 PM, Patrick Patterson wrote:
 

Hey there:

It should be noted that this is an EXCEEDINGLY BAD thing to do, since it more
or less removes any control that the CA has over the certificates that it
issues, and unless the Registration Authority is VERY careful about examining
all of the requests in detail, all manner of evil and bad things could happen,
including:

- The CA could inadvertantly create a SubCA, if the request has
basicConstraints: CA:TRUE and the appropriate keyUsage fields set.

- The CA could sign for SAN values that it has not proofed.

- The CA could sign for keyUsage and ExtendedKeyUsage values which it may not
grant or wish to grant the Subscriber Certificate

- The CA could sign asserting that the end-entity certificate conforms to a
policy that it does not (leading to potentially serious legal implications for
the CA including charges of fraud and misrepresentation).

All that the attacker has to do with this option enabled is supply the CA with
an request with each or all of those extensions present and appropriately
configured.

All in all, unless this is a test CA that is clearly marked as non-
trustworthy, then this is probably not at all what you want to do, and could
have potentially serious implications not only at a technical level, but at a
liability and organisational level.

Best Regards,

Patrick.

On September 19, 2010 09:20:51 pm Gaiseric Vandal wrote:

   

FYI, enabling the following line in openssl.cnf has resolved the problem.



copy_extensions = copy







From: Gaiseric Vandal [mailto:gaiseric.van...@gmail.com]
Sent: Saturday, September 18, 2010 7:09 PM
To: openssl-users@openssl.org
Subject: RE: Confusion about subject alternative names



Some additional info:



My openssl.cnf file includes the following



---
- ---

policy  = policy_anything



[ policy_anything ]

countryName = optional

stateOrProvinceName = optional

localityName= optional

organizationName= optional

organizationalUnitName  = optional

commonName  = supplied

emailAddress= optional

subjectAltName  = optional

..



# req_extensions = v3_req # The extensions to add to a certificate request



[ req_distinguished_name ]..

subjectAltName  = Subject Alternate Name


Re: Confusion about subject alternative names - resolved

2010-09-22 Thread Patrick Patterson
On 2010-09-22, at 6:38 PM, Gaiseric Vandal wrote:

 Thanks for the link.
 
 I still need the CA to load the SAN parameter from the request-  it looks 
 like a lot of the defaults would be to copy the e-mail address into the SAN 
 field.
 

Why? Why not just have the CA just put the appropriate value into the end 
Certificate?

 I don't use openssl at this point to generate certs for users.  No one 
 besides me uses openssl ca on this server anyway.   Of course, that doesn't 
 stop anyone from using openssl on their own machine to create whatever keys 
 and certs they want anyway-  I could create CA configuration for 
 microsoft.com and use it to create send Secure e-mail from microsoft.
 
If you don't use OpenSSL to generate certs, what tool are you using to Sign 
them then (generating and signing certs are pretty much the same option - 
perhaps you meant that you don't use OpenSSL to generate keypairs and CSRs?)?

 If I start dealing with user certificates then I would probably need a more 
 full featured CA solution that allows web-based user requests and key escrow. 
I have started tinkering with the DogTag (opensource version of redhat 
 cert server) but so far not sure if it supports the SAN extensions properly.  
 I may have to suck it up and just install the MS CA services to have 
 something that plays nice with MS Exchange and other MS services.  I try to 
 avoid MS Solutions because they tend to optimize standards.
 

I'm not sure what you are talking about - DogTag (and RedHat cert server) 
definitely can be configured to do just about anything you may need. And 
OpenSSL has absolutely no problem generating any certs that a Microsoft 
environment may need. Having OpenSSL generate certs that are usable for 
Exchange is rather trivial.

Anyways - Have fun.

---
Patrick Patterson
President and Chief PKI Architect
Carillon Information Security Inc.
http://www.carillon.ca

tel: +1 514 485 0789
mobile: +1 514 994 8699
fax: +1 450 424 9559





__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Self-signed CA problem for internal web application

2010-09-22 Thread Patrick Patterson
Hi Chris:
On 2010-09-22, at 4:13 PM, Chris Rider wrote:

 For now, I've just copied the CA's public .crt file to a public_html type 
 directory and downloading on the client ~ from there, depending on whether I 
 use FireFox or IE, I go into the respective certificates manager and import 
 the one I downloaded. I've been very deliberate in making sure it actually 
 gets installed under the root/trusted category, and not some other category.
 
 I haven't investigated the AIA field... (didn't even know about it)
 
 Would that be specified when creating the CA's keys? Is that best specified 
 in my CA's cnf file somewhere?
 

Yes - it would. 

 Barring all else, it seems to me like the browser is hanging up on the fact 
 that the CA's certificate is self-signed. (??)
 

Things that would make the browser hang include:

CA cert not including basicConstraints: CA=True, or keyUsage not including 
certSign.
and
User Certs that DO include either of those values.

Also, what could be happening is a mismatch between AKI and SKI values in the 
CA and Server certs.

That's why I requested you to send along a copy of the certs that you are using 
- the values need to be set correctly, just having one key signed by the other, 
which happens to be self signed, is not enough. Unless you have extensively 
edited your openssl.cnf file, you are probably not generating correct CA or end 
entity certs.

Have fun.

Patrick.


 -Chris
 
 
 Hugo Garza wrote:
 Hi Chris, how are you installing the root CA on the client machines?
 
 In windows once you double click the root certificate you get a message 
 dialog box and click the install certificate button. On the following screen 
 press next and on the next screen tell it to install the certificate to the 
 Trusted Root Certificate Authorities, hit next then finish. You should get a 
 Windows dialog warning saying that you are adding a root certificate, and 
 you just say yes.
 
 Now the other possible problem is that on the server certificate that you 
 created you aren't including the Authority Information Access (AIA) field. 
 This is crucial so that your customers only have to install the root CA and 
 implicitly trust any certificates signed by the root.
 
 On Wed, Sep 22, 2010 at 2:29 PM, Chris Rider 
 chris.ri...@messagenetsystems.com 
 mailto:chris.ri...@messagenetsystems.com wrote:
 
We have a client/server architecture based product that needs to
allow SSL communication between our server (CentOS) and various
clients' web browsers (and additionally, other devices, but that's
beyond the scope of this post).
 
We've been able to get SSL working in both of two different ways
(self-signed certificate  self-signed CA with certificates signed
by that) -- so that is not the issue. Rather, our whole issue is
that we don't want the end-users to confronted with a big scary
browser message that says something akin to There's a Problem
With Security! / Allow Exception, etc. If they must install a
certificate or two, that would be acceptable, though. So I thought
that creating my own CA to sign certificates with would be a
solution apparently not. I'm now getting browser messages that
say the certificate's issuer is not trusted!!! Very frustrating.
 
So, as I said, I've created my own CA (using this link as a guide:
http://www.g-loaded.eu/2005/11/10/be-your-own-ca/ ), and can sign
my own certificates without problem. I then install the root
certificate, followed by a server certificate signed by that CA.
And, while I can click allow exception in the browser to make it
all work, that is not the desired way. We just want to be able to
have the end-user install a trusted root certificate and
everything just work from there. Testing in IE and FireFox nets
the same big scary warning message, no matter what combination of
fields I use in the CSR, etc.
 
We really don't want to go with a third party CA like VeriSign,
for example -- not so much because of the cost, but we just don't
want to deal with updating countless remote installations of our
product whenever the certificate expires. Not to mention the
support that would be associated with doing that! The other issue
is that some/most of these installations do not have outside
internet connectivity with which to query the CA's (for CRL's, or
whatever). We really need to manage our own certificates, all in
all but without these warning messages.
 
Is it possible?
If so, what am I missing?
 
-- Chris Rider,
Systems Architect
MessageNet Systems
__
OpenSSL Project http://www.openssl.org
User Support Mailing List   openssl-users@openssl.org 
 mailto:openssl-users@openssl.org
Automated List Manager  majord...@openssl.org 

RE: Confusion about subject alternative names - resolved

2010-09-22 Thread Gaiseric Vandal
I use openssl to create certs for servers only, not for users.   If I create
a key with openssl, then create a CSR with openssl req, it would prompt me
for a subjectAltName.Openssl ca will sign CSR's from MS Exchange but not
would include the subjectAltName until I enabled copy extensions.  When I
create a CSR on MS Exchange, the key is automatically created as well.  


In the PDF you suggested, there is the following examples... 

___

The following section in openssl-ext.cnf shows how extensions compatible
with the above
can be produced in a certificate generated by OpenSSL:

[ usr_id_ext ]
basicConstraints = CA:FALSE
keyUsage = critical, digitalSignature
nsComment = Do Not trust ID
Cert for CertiPath interop TEST purposes only
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
subjectAltName = email:$ENV::EMAILADDR
authorityInfoAccess = @aia_points
crlDistributionPoints = @crl_dist_points
certificatePolicies = ia5org, @my_medium_sw_policy


[ usr_sign_ext ]
basicConstraints = CA:FALSE
keyUsage = critical, digitalSignature, nonRepudiation
extendedKeyUsage = emailProtection, anyExtendedKeyUsage
nsComment = Do Not trust Signature
Cert for CertiPath interop
only
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
subjectAltName = email:$ENV::EMAILADDR
authorityInfoAccess = @aia_points
crlDistributionPoints = @crl_dist_points
certificatePolicies = ia5org, @my_medium_sw_policy

___
   
To me this looks like it is configured to pick up the e-mail address from
the CSR.

Or maybe I need a separate openssl-ext.cnf file?


My openssl.cnf file includes the following (I think I put some of this in
the original post...)



___
[ policy_anything ]
...
subjectAltName  = optional
...
# req_extensions = v3_req # The extensions to add to a certificate request

[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = US
countryName_min = 2
countryName_max = 2
...
# I added the following line 
subjectAltName  = Subject Alternate Name
subjectAltName_default  = www.foo.com

[ v3_req ]

# Extensions to add to a certificate request

basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment


___



If I set the policy to require a SAN, openssl ca will reject the CSR's
from MS Exchange, but I think it will be OK with the CSR's from openssl
req. I am not sure if this means that openssl.cnf is not configured to
have the ca create certs with v3 extensions? 

Re DogTag-  I don't think I have tried having DogTag sign a SAN CSR from
MS Exchange.  It had trouble signing SAN CSR's that I generated with
openssl req.  My understanding had been that not all CA's supports SAN
anyway. This is probably something for the pki-us...@redhat.com forum.   I
suspect that the problem may have been with openssl not DogTag.  


Apart from the SAN issue, OpenSSL has been able to handle creating keys and
certs to use with MS Apps, or signing CSR's created by MS IIS or MS
Exchange.  (sometimes you have to convert certs from PEM to DER or vice
versa.)  

Thanks for your help.


 

-Original Message-
From: owner-openssl-us...@openssl.org
[mailto:owner-openssl-us...@openssl.org] On Behalf Of Patrick Patterson
Sent: Wednesday, September 22, 2010 6:48 PM
To: openssl-users@openssl.org
Subject: Re: Confusion about subject alternative names - resolved

On 2010-09-22, at 6:38 PM, Gaiseric Vandal wrote:

 Thanks for the link.
 
 I still need the CA to load the SAN parameter from the request-  it looks
like a lot of the defaults would be to copy the e-mail address into the SAN
field.
 

Why? Why not just have the CA just put the appropriate value into the end
Certificate?

 I don't use openssl at this point to generate certs for users.  No one
besides me uses openssl ca on this server anyway.   Of course, that doesn't
stop anyone from using openssl on their own machine to create whatever keys
and certs they want anyway-  I could create CA configuration for
microsoft.com and use it to create send Secure e-mail from microsoft.
 
If you don't use OpenSSL to generate certs, what tool are you using to Sign
them then (generating and signing certs are pretty much the same option -
perhaps you meant that you don't use OpenSSL to generate keypairs and
CSRs?)?

 If I start dealing with user certificates then I would probably need a
more full featured CA solution that allows web-based user requests and key
escrow.I have started tinkering with the DogTag (opensource version of
redhat cert server) but so far 

Re: Confusion about subject alternative names - resolved

2010-09-22 Thread Patrick Patterson
Hi there:

See my answer inline:

On 2010-09-22, at 8:06 PM, Gaiseric Vandal wrote:

 I use openssl to create certs for servers only, not for users.   If I create
 a key with openssl, then create a CSR with openssl req, it would prompt me
 for a subjectAltName.Openssl ca will sign CSR's from MS Exchange but not
 would include the subjectAltName until I enabled copy extensions.  When I
 create a CSR on MS Exchange, the key is automatically created as well.  
 
 
 In the PDF you suggested, there is the following examples... 
 
 ___
 
 The following section in openssl-ext.cnf shows how extensions compatible
 with the above
 can be produced in a certificate generated by OpenSSL:
   
 [ usr_id_ext ]
 basicConstraints = CA:FALSE
 keyUsage = critical, digitalSignature
 nsComment = Do Not trust ID
 Cert for CertiPath interop TEST purposes only
 subjectKeyIdentifier = hash
 authorityKeyIdentifier = keyid,issuer
 subjectAltName = email:$ENV::EMAILADDR
 authorityInfoAccess = @aia_points
 crlDistributionPoints = @crl_dist_points
 certificatePolicies = ia5org, @my_medium_sw_policy
 
 
 [ usr_sign_ext ]
 basicConstraints = CA:FALSE
 keyUsage = critical, digitalSignature, nonRepudiation
 extendedKeyUsage = emailProtection, anyExtendedKeyUsage
 nsComment = Do Not trust Signature
 Cert for CertiPath interop
 only
 subjectKeyIdentifier = hash
 authorityKeyIdentifier = keyid,issuer
 subjectAltName = email:$ENV::EMAILADDR
 authorityInfoAccess = @aia_points
 crlDistributionPoints = @crl_dist_points
 certificatePolicies = ia5org, @my_medium_sw_policy
 
 ___
 
 To me this looks like it is configured to pick up the e-mail address from
 the CSR.
 

No, they get them from environment variables of the shell that you are using 
(ENV::EMAILADDR says to get the value for that out of a shell environment 
variable called EMAILADDR. If you read the entire howto, you would see 
several shell scripts that help you create exactly what it is that you are 
trying to create (including ones for Devices, and Microsoft Communications 
Services (or whatever they are calling them these days) servers).

 Or maybe I need a separate openssl-ext.cnf file?
 

If you follow the steps in the docs, you should get an OpenSSL configuration 
for a CA that allows you to do everything that you would want to, and more.

 
 My openssl.cnf file includes the following (I think I put some of this in
 the original post...)
 
 
 
 ___
 [ policy_anything ]
 ...
 subjectAltName  = optional
 ...
 # req_extensions = v3_req # The extensions to add to a certificate request
 
 [ req_distinguished_name ]
 countryName = Country Name (2 letter code)
 countryName_default = US
 countryName_min = 2
 countryName_max = 2
 ...
 # I added the following line 
 subjectAltName  = Subject Alternate Name
 subjectAltName_default  = www.foo.com
 
 [ v3_req ]
 
 # Extensions to add to a certificate request
 
 basicConstraints = CA:FALSE
 keyUsage = nonRepudiation, digitalSignature, keyEncipherment
 
 
 ___
 
 
 
 If I set the policy to require a SAN, openssl ca will reject the CSR's
 from MS Exchange, but I think it will be OK with the CSR's from openssl
 req. I am not sure if this means that openssl.cnf is not configured to
 have the ca create certs with v3 extensions? 
 

Don't set the policy - set up your openssl.cnf files to correctly populate the 
extensions. You should NOT have any mention of SAN in either the 
req_distinguished_name section or the policy section. Instead, you should have 
the correct values being populated into the SAN in your own version of the 
v3_ext section.

 Re DogTag-  I don't think I have tried having DogTag sign a SAN CSR from
 MS Exchange.  It had trouble signing SAN CSR's that I generated with
 openssl req.  My understanding had been that not all CA's supports SAN
 anyway. This is probably something for the pki-us...@redhat.com forum.   I
 suspect that the problem may have been with openssl not DogTag.  
 
 
No - just about everything supports SAN, all you have to do is configure your 
CA correctly. I have yet (in over 10 years of playing around with PKI) to run 
into any CA that does NOT handle SAN. Most will not get it out of the Subject 
DN (since it is a horrible, horrible idea, and definitely not in line with best 
practice) of the Certificate Request, but everything will correctly handle it 
when building a certificate. Even ancient versions of OpenSSL could handle all 
of the various different kinds of values that you could put in SAN, although 
you had to be fairly proficient in encoding