How to insert a Publickey in a Keystore file without using keytoland wihtout a cert file ?

Discussion in 'Java' started by Pedro Martins, Feb 20, 2006.

  1. After i read java.security.cert and java.security.keystore i didn't find
    any solution of my problem.
    The problem is that i want to create n keystores without using the
    keytool because i want to export the solution to use with smartcards.
    This issue i can do it.
    The big problem is after created the public and private key (RSA 1024)
    the keystore only allows entry Keystore.PrivateKeyEntry (private key +
    certificate chain for the corresponding public key)
    How can i do this?
    Creat a autocertificate file wiht keytool?
    Because i wanted to do with code
    Thank you for all the help
     
    Pedro Martins, Feb 20, 2006
    #1
    1. Advertising

  2. Pedro Martins

    robert Guest

    Re: How to insert a Publickey in a Keystore file without using keytol and wihtout a cert file ?

    Pedro Martins escreveu:

    > After i read java.security.cert and java.security.keystore i didn't find
    > any solution of my problem.
    > The problem is that i want to create n keystores without using the
    > keytool because i want to export the solution to use with smartcards.
    > This issue i can do it.
    > The big problem is after created the public and private key (RSA 1024)
    > the keystore only allows entry Keystore.PrivateKeyEntry (private key +
    > certificate chain for the corresponding public key)
    > How can i do this?
    > Creat a autocertificate file wiht keytool?
    > Because i wanted to do with code
    > Thank you for all the help


    Not sure I understand your question. Lets try to focus on what the
    Private Key can do and what you want it to do:

    PrivateKey pk = null;
    java.security.KeyStore ks =
    java.security.KeyStore.getInstance(storetype)

    pk = (PrivateKey)ks.getKey(privateKeyAlias,
    privateKeyPass.toCharArray());

    Now, you can store this pk somewhere because it implements
    'serializable' . That means it can be store in LDAP for example using
    java.schema .

    Now you typically need a public key to sign something, often with X509
    - which also implements 'serializable' .

    X509Certificate cert =
    (X509Certificate)ks.getCertificate(privateKeyAlias);

    sig.addKeyInfo(cert);
    sig.addKeyInfo(cert.getPublicKey());
    // Sign the XML Signature document with our private key
    sig.sign(privateKey);

    Does the above solve, or not solve, your problem? It seems like you
    canĀ“t create the cert - not sure why.

    HTH,
    iksrazal
    http://www.braziloutsource.com/
     
    robert, Feb 20, 2006
    #2
    1. Advertising

  3. Pedro Martins

    Roedy Green Guest

    Re: How to insert a Publickey in a Keystore file without using keytol and wihtout a cert file ?

    On Mon, 20 Feb 2006 17:19:09 +0000, Pedro Martins
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Creat a autocertificate file wiht keytool?


    you need to get a book on how the JCE interface works. Read the Feghi
    book. It is full of complete examples. It is somewhat dated, but it
    will get you started.. See http://mindprod.com/jgloss/jce.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 24, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rogue Chameleon

    KeyStore and PublicKey

    Rogue Chameleon, Sep 27, 2004, in forum: Java
    Replies:
    3
    Views:
    408
    Sudsy
    Sep 27, 2004
  2. Sven Bluege
    Replies:
    1
    Views:
    841
    Roedy Green
    Sep 21, 2005
  3. =?Utf-8?B?RGFuaWVsIERpIFZpdGE=?=

    Render UserControl in Class wihtout access to webform?

    =?Utf-8?B?RGFuaWVsIERpIFZpdGE=?=, Aug 1, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    396
    =?Utf-8?B?RGFuaWVsIERpIFZpdGE=?=
    Aug 1, 2007
  4. Ian Pilcher
    Replies:
    3
    Views:
    647
    sharonbn
    Oct 21, 2012
  5. David Chan via .NET 247
    Replies:
    1
    Views:
    344
    Dominick Baier [DevelopMentor]
    Jun 2, 2005
Loading...

Share This Page