• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a .der (file generated by openssl rsageberate command) file from classpath

 
Juhi Bhatia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to read the private key from the .der file generated by openssl rsagen command. I am reading the file in the junit test case using the following piece of code, but the assertnotnull(privateKey ) is returning null, that means the private key is not read from the file. Need urgent help.


I have copied the der file in the same folder as this unit test case. Any help is appreciated.
Thanks,
Juhi.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's most likely that you're simply not finding the der file in the first place, so there's nothing to read. It's a bit tricky to get this right, but the idea is to give the name of a resource, and the system will look for it in the classpath. However, if you just provide a root level name like "key.der", it's just going to look in the root folder of each classpath entry. You've said that you put the file in the same directory as the unit test case ... and I assume you mean the class file. That means it's in the classpath, but buried in the package com.entrib.emg.server.controller. You either have to move key.der up to the root level, or change the resource name to com/entrib/emg/server/controller/key.der.

 
Juhi Bhatia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg,
Thanks for your reply. I have already found a solution for it and its same as your suggestion. I just placed the key.der file under resources and could read it.

Thanks,
Juhi.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!