Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > BOOK: Beginning Cryptography with Java
|
BOOK: Beginning Cryptography with Java
This is the forum to discuss the Wrox book Beginning Cryptography with Java by David Hook; ISBN: 9780764596339
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Cryptography with Java section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2009, 04:07 PM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Character 6 - Creating a self-signed cert

I want to create a self-signed Version 1 Certificate.

I tried the example on Character 6 and it works, I think. (I did not get any errors and the output shows that everything is fine.)

My questions are:
  1. Where is the certificate file? Is it stored in c:\??
  2. What filename is used for this certificate?
 
Old August 25th, 2009, 06:18 PM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

The example does not save the certificate to disk. To do that you need to store the bytes returned by the getEncoded() method on the certificate. Have a look at the CertificateFactoryExample to see how the output and recovery process works.

Regards,

David
 
Old August 26th, 2009, 08:24 AM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. I will try the CertificateFactoryExample.
 
Old April 10th, 2010, 01:26 PM
Registered User
 
Join Date: Apr 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Unresolved compilation problems:

I can't compile the v1, v3 and CertificateFactoryExample:
Following Exception:
Code:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
	The method setIssuerDN(X509Name) in the type X509V3CertificateGenerator is not applicable for the arguments (X500Principal)
	The method setSubjectDN(X509Name) in the type X509V3CertificateGenerator is not applicable for the arguments (X500Principal)

	at chapter6.X509V3CreateExample.generateV3Certificate(X509V3CreateExample.java:32)
	at chapter6.X509V3CreateExample.main(X509V3CreateExample.java:58)
A possible quick fix is to change the
Code:
setIssuerDN()
to
Code:
setIssuerUniqueID()
but it's also not compileable.

I'm using Eclipse SDK v3.5.2 Galileo
 
Old April 10th, 2010, 06:59 PM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

You would only expect to see this if you were using a very old version of the BC API (pre book even) or you're using the JDK 1.3 version and trying to work with Java 1.4 or later.

What version of BC and Java are you using?

Regards,

David
 
Old April 11th, 2010, 04:09 AM
Registered User
 
Join Date: Apr 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Even mentioned in the Book to use the JDK 1.3 and java 1.4 I thought the latest Java version should include the 1.4 standarts.
So I'm up to date with Java 1.6 and I'm using the latest JDK. The BC is also the latest crypto 1.4.5 package. What a falsity.
So the JDK should be not higher than 1.3 and running java 1.6 is acceptable?
And how about the BC version?
Thanks for your fast reply dgh
Regards
 
Old April 11th, 2010, 04:29 AM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

If you're using JDK 1.6, bcprov-jdk16-145.jar, should work fine.

One other thing - the generator class you're using is in the package org.bouncycastle.x509 isn't it? This is how it's defined in the examples, however if you've used cut and paste and accidentally imported the deprecated class you won't find a method for handling an X500Principal.

Regards,

David
 
Old April 11th, 2010, 05:14 AM
Registered User
 
Join Date: Apr 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Indeed, the
Code:
setIssuerDN
Method is fixed but the
Code:
X500Principal
cannot be resolved as a type. I imported the Project with all
Code:
chapter.packages
. And I switched the JDK to 1.3. If I switch back to 1.6 the
Code:
setIssuerDN
causes the problem and
Code:
X500Principal
looks fine. THAT's weird
 
Old April 11th, 2010, 05:45 AM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

Yes, X500Principal only exists in JDK 1.4 and later. You need to check your classpath - it sounds like you might have two versions of the BC jar in your classpath. The alternative is your IDE has somehow imported the deprecated version of the generators.

If you look at the source for org.bouncycastle.x509.X509V3CertificateGenerator.j ava you will see there are methods for X500Principal.

Regards,

David
The Following User Says Thank You to dgh For This Useful Post:
Chris07 (April 11th, 2010)
 
Old April 11th, 2010, 06:29 AM
Registered User
 
Join Date: Apr 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Talking

Ja thx man,
i switched back to the jdk 1.6 and relinked the class_path variables in the environment to the jdk 1.6 folder. After that I had a look at the imported libraries jars and removed all duplicated jars (jre1.2 - jre 1.5) that jre 1.6 left over. BANG - the hole project appered CLEAR and compielable.
I appreciate your help
Thx again XD
Great Forum
Chris





Similar Threads
Thread Thread Starter Forum Replies Last Post
guide me to know data for to prepare sun java cert keyeni Java Basics 2 March 14th, 2008 04:58 AM
cert sites? vartham Need help with your homework? 1 October 28th, 2006 12:22 PM
Extract from file cannot be signed connlichan Infopath 0 October 24th, 2005 08:10 PM
Mutual authentication & null cert chain exception S M Humayun J2EE 1 September 6th, 2004 02:35 AM
Signed Applet example? EhobaX Java GUI 1 January 6th, 2004 06:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.