• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic