Creating the Top-level (Root) CA Key problem

TM <[email protected]> Mon, 27 Oct 2014 07:42:59 +0100
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <[email protected]>
Hello.

When creating CA key + cert using steps from manual s. 169 I am getting 
permission error (-21) with:
cryptSetAttribute( cryptCertificate, 
CRYPT_CERTINFO_AUTHORITYINFO_CERTSTORE, CRYPT_UNUSED );

It works without without setting urls.

I am using Delphi XE2 with Wolfgangs DelphiCryptlib library.

Beneath is en equivalent in code that I am  using to create Root CA Cert.


Code:

CRYPT_CONTEXT cryptContext;
/* Create an RSA public/private key context, set a label for it, and 
generate a key into it */
cryptCreateContext( &cryptContext, cryptUser /* CRYPT_UNUSED */, 
CRYPT_ALGO_RSA );
cryptSetAttributeString( cryptContext, CRYPT_CTXINFO_LABEL, "Private 
key", 11 );
cryptGenerateKey( cryptContext );

CRYPT_CERTIFICATE cryptCertificate;
/* Create the CA certificate and add the public key */
cryptCreateCert( &cryptCertificate, cryptUser /* CRYPT_UNUSED */, 
CRYPT_CERTTYPE_CERTIFICATE );
cryptSetAttribute( cryptCertificate, 
CRYPT_CERTINFO_SUBJECTPUBLICKEYINFO, cryptContext );
/* Add identification information */
cryptSetAttributeString( cryptCertificate, CRYPT_CERTINFO_COUNTRYNAME, 
countryName, 2 );
cryptSetAttributeString( cryptCertificate, 
CRYPT_CERTINFO_ORGANIZATIONNAME, organizationName, organizationNameLength );
cryptSetAttributeString( cryptCertificate, 
CRYPT_CERTINFO_ORGANIZATIONALUNITNAME, organizationalUnitName, 
organizationalUnitNameLength );
cryptSetAttributeString( cryptCertificate, CRYPT_CERTINFO_COMMONNAME, 
commonName, commonNameLength );

cryptSetAttribute( cryptCertificate, CRYPT_CERTINFO_SELFSIGNED, 1 );
cryptSetAttribute( cryptCertificate, CRYPT_CERTINFO_CA, 1 );


cryptSetAttribute( cryptCertificate, 
CRYPT_CERTINFO_AUTHORITYINFO_CERTSTORE, CRYPT_UNUSED );  <-- Problem
cryptSetAttributeString( cryptCertificate, 
CRYPT_CERTINFO_UNIFORMRESOURCEIDENTIFIER, certstoreUrl, 
certstoreUrlLength );
cryptSetAttribute( cryptCertificate, CRYPT_CERTINFO_AUTHORITYINFO_RTCS, 
CRYPT_UNUSED );
cryptSetAttributeString( cryptCertificate, 
CRYPT_CERTINFO_UNIFORMRESOURCEIDENTIFIER, rtcsUrl, rtcsUrlLength );

cryptSignCert( cryptCertificate, cryptContext );

CRYPT_KEYSET cryptKeyset;
/* Save the generated public/private key pair to a keyset */
cryptKeysetOpen( &cryptKeyset, cryptUser /* CRYPT_UNUSED */, 
CRYPT_KEYSET_FILE, fileName, CRYPT_KEYOPT_CREATE );
cryptAddPrivateKey( cryptKeyset, cryptContext, password );
cryptAddPublicKey( cryptKeyset, cryptCertificate );
cryptKeysetClose( cryptKeyset );
/* Clean up */
cryptDestroyContext( cryptContext );
cryptDestroyCert( cryptCertificate );

cryptAddPublicKey( cryptDevice, cryptCertificate );
/* Clean up */
cryptDestroyCert( cryptCertificate );


Regards
Tomasz Markiewicz


_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.