Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Other Java > BOOK: Beginning Cryptography with Java
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 9th, 2015, 08:28 AM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2015
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default Java KeyStore not reading entries from .p12 file

I have modified the instance type of the key store provider on the repository.

Now the certificates are correctly written to the file client.p12 and can be read using the keytool:

Code:
$ keytool -list -keystore client.p12 -storepass clientPassword -v -storetype PKCS12

Keystore type: PKCS12
Keystore provider: SunJSSE

Your keystore contains 1 entry

Alias name: client
Creation date: Nov 9, 2015
Entry type: PrivateKeyEntry
Certificate chain length: 3
Certificate[1]:
Owner: CN=End Certificate
Issuer: CN=Intermediate Certificate
Serial number: 40f960450ce16070
Valid from: Mon Nov 09 12:08:34 EET 2015 until: Mon Nov 16 12:08:34 EET 2015
Certificate fingerprints:
         MD5:  2C:1F:97:91:B9:33:D3:F4:4F:89:AA:13:43:53:F5:8A
         SHA1: 41:83:C7:57:CE:B8:BC:DC:AC:E1:58:20:27:9E:05:CC:F2:F0:37:6C
         SHA256: 58:57:EA:83:F7:66:45:80:EF:0E:39:8D:60:9C:C4:C8:CF:7A:74:06:07:DE:37:E0:DF:5F:0C:5C:D6:D3:0D:AC
         Signature algorithm name: SHA256withRSA
         Version: 3

Extensions:

#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 1E 5E A8 36 64 31 32 5B   83 9F CF 9F F3 5F F0 17  .^.6d12[....._..
0010: EF 83 12 E5                                        ....
]
]

#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
  CA:false
  PathLen: undefined
]

#3: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
  DigitalSignature
  Non_repudiation
  Key_Encipherment
  Data_Encipherment
  Key_CertSign
  Crl_Sign
]

Certificate[2]:
Owner: CN=Intermediate Certificate
Issuer: CN=Root
Serial number: 6d5f5d9bb7b110df
Valid from: Mon Nov 09 12:08:34 EET 2015 until: Mon Nov 16 12:08:34 EET 2015
Certificate fingerprints:
         MD5:  0A:F1:DD:AC:15:3C:90:8F:A5:BA:72:B9:40:FB:1E:D2
         SHA1: 78:DD:64:37:8F:94:F4:A1:F1:5E:80:70:89:18:0A:F4:6B:07:F8:3C
         SHA256: DF:04:BB:DD:72:85:E0:CB:83:C6:73:E0:7D:F5:F3:E9:54:4E:D1:32:8C:74:A2:31:AE:BF:7A:FD:FE:29:D3:7D
         Signature algorithm name: SHA256withRSA
         Version: 3

Extensions:

#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 39 C5 42 A1 3D 0F B9 5F   C7 EA 32 9C 18 03 63 3D  9.B.=.._..2...c=
0010: 65 0F 30 22                                        e.0"
]
]

#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
  CA:false
  PathLen: undefined
]

#3: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
  DigitalSignature
  Non_repudiation
  Key_Encipherment
  Data_Encipherment
]

Certificate[3]:
Owner: CN=Root
Issuer: CN=Root
Serial number: 2c8b7a0f9a68a4d1
Valid from: Mon Nov 09 12:08:34 EET 2015 until: Mon Nov 16 12:08:34 EET 2015
Certificate fingerprints:
         MD5:  37:29:09:F2:E5:98:E1:EC:86:35:4E:A5:7F:54:06:70
         SHA1: 59:97:7E:3B:7B:5B:C5:A4:CA:17:92:24:60:EF:CE:4E:34:9D:4D:4A
         SHA256: B1:7B:20:EA:09:8E:72:3A:BC:59:54:9C:7B:78:0C:D7:45:D0:3C:90:AB:81:69:78:75:3E:B9:D1:CA:01:6B:D9
         Signature algorithm name: SHA256withRSA
         Version: 1


*******************************************
*******************************************
But when I try to read them programmatically:

Code:
// set up a key manager for our local credentials

	        KeyManagerFactory mgrFact = KeyManagerFactory.getInstance("SunX509");

	        KeyStore clientStore = KeyStore.getInstance("PKCS12");

	 

	        clientStore.load(new FileInputStream(CLIENT_NAME + ".p12"), CLIENT_PASSWORD); //  <== CLIENT STORE CONTAINS NO ENTRIES

	 

	        mgrFact.init(clientStore, CryptographyUtils.CLIENT_PASSWORD);
the client store is not initialized. Why?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java KeyStore not storing whole certificate chain Sebi BOOK: Beginning Cryptography with Java 2 November 9th, 2015 08:35 AM
Reading a schema's facets using Java WilliamYou BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 8 October 11th, 2012 09:47 AM
Solution to the Strange User File entries Wolven BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 April 24th, 2007 07:40 PM
Strange User File entries... Wolven BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 April 23rd, 2007 02:32 AM
reading excel file in java uttam.mca Pro JSP 1 July 14th, 2006 07:29 PM



All times are GMT -4. The time now is 10:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.