How to read a PrivateKey that has been generated using Openssl.

I used openssl to generate the key pairs,,the commands are as follows
openssl req -config openssl.cnf -new -out buyer.csr
openssl rsa -in privkey.pem -out buyer.key
openssl x509 -in buyer.csr -out buyer.cert -req -signkey buyer.key -days 365
openssl x509 -in buyer.cert -out buyer.der.crt -outform DER
now i have buyer.key as my private key,,,i like to read it to sign a file but i get error while doing it,,the code for doing it is as follows
import java.io.*;
import java.security.*;
import java.security.spec.*;
import java.security.spec.X509EncodedKeySpec;
class clientEncrypt {
public static void main(String[] args) {
PrivateKey priv=null;
try{             
FileInputStream in = new FileInputStream("C:/certificates/suepkb");
byte[] encodedKey = new byte[in.available()];
in.read(encodedKey);
in.close();
X509EncodedKeySpec privateKey = new X509EncodedKeySpec(encodedKey);
KeyFactory kf = KeyFactory.getInstance("RSA");
priv = kf.generatePrivate(privateKey);
}catch(Exception e){
System.out.println("subhash"+e.getMessage());
try{  
Signature dsa = Signature.getInstance("SHA1withRSA");
dsa.initSign(priv);
/* Update and sign the data */
FileInputStream fis = new FileInputStream("c:/sub.txt");
BufferedInputStream bufin = new BufferedInputStream(fis);
byte[] buffer = new byte[1024];
int len;
while (bufin.available() != 0) {
len = bufin.read(buffer);
dsa.update(buffer, 0, len);
bufin.close();
/* Now that all the data to be signed has been read in,
generate a signature for it */
byte[] realSig = dsa.sign();
/* Save the signature in a file */
FileOutputStream sigfos = new FileOutputStream("c:/ssig");
sigfos.write(realSig);
sigfos.close();
/* Save the public key in a file */
} catch (Exception e) {
System.err.println("Caught exception " + e.toString());
plz do help me out,,,asap
with regd and thnx in advnce
Subhash

use bouncycastle provider.
there are some classes and a sample code for this.

Similar Messages

  • How do I find music that has been uploaded to iTunes from a purchased CD and iTunes is "unable to find the original file?" I no longer have the CD. I have tried all the usual methods of looking in my iTunes library and through Find. No Luck.

    How do I find music that has been uploaded to iTunes from a purchased CD and iTunes is “unable to find the original file?” I no longer have the CD. I have tried all the usual methods of looking in my iTunes library and through Find. No Luck.

    Backup drive?
    Subscribe to iTunes Match?
    If neither of the above and you don't have the CD and can't find your tracks on the computer then they you're stuck.  A file recovery utility will cost $100, plus another $100 for an external drive to which to resue the files, and may not even work.  You can buy a lot of CDs for $200.

  • How to get PDF file that has been transformed into docx into my filing system so I can work on it???

    How can I get the PDF file that was transformed into a docx file into my filing system to be able to work on it and translate it as the customer requested?

    THanks for your reply.
    Well what happens is I bought the program. It gives you a button to click,
    you log in and then a box opens up asking you to select the file, I go into
    my filing system (in Windows explorer) select the file, and the program
    converts it into docx, my choice.  I can read it there and when I try to
    copy and paste it into my file where the PDF version is saved, it behaves
    like an "image", and I can't save it.... or it saves likes something you
    save on the internet, so you have to go into internet every time you want
    to see it.    I have also pressed any amount of buttons to see if it will
    give me the option to save it any other way, and have found nothing.  What
    I would need is a file in docx.format that I can edit.  People send me
    things in PDF and sometimes I can just copy it off the PDF file and save it
    in WOrd, then I can translate it for them. But sometimes the PDF file
    doesnt allow me to copy the text.  If it is in image form, I cannot work on
    it.  It means printing it, so I can copy type it into Word... and for that
    I certainly wouldnt need to buy a program.  Its just double the work and
    ends up that the job takes twice as long.!
    Sorry  if I am a bit dumb with informatics.  But I simply could not find
    any way whatever to  copy the PDF file that was transformed into Word, in a
    format that would enable me to edit it.
    Kindest regards,
    Margery
    2013/12/2 Test Screen Name <[email protected]>
        Re: How to get PDF file that has been transformed into docx into my
    filing system so I can work on it???
    created by Test Screen Name<http://forums.adobe.com/people/TestScreenName>in *Adobe
    ExportPDF* - View the full discussion<http://forums.adobe.com/message/5890871#5890871

  • TS4036 How do I access content that has been backed up to iCloud?  I no longer have an iphone, but want to access the music/pictures I've stored to the cloud.  When I logged into iCloud, there was no tab or option to view store content.  Please help.

    How do I access content that has been backed up to iCloud?  I no longer have an iphone, but I want to access the music/pictures I've stored to the cloud.  When I logged in to iCloud, there was no tab or option to view content.  Please help.

    Without an iPhone or iPod Touch to restore the backup to, you cannot access the camera roll photos stored in the iCloud backup.  Signing into the account on your computer and enabling photo stream will only allow you to access photo stream photos from the last 30 days, and any shared stream you were subscribed to.
    You can redownload purchased music in iTunes on your computer as explained here: http://support.apple.com/kb/ht2519.

  • I would like to know if you have to back up a macbook hard drive, can I use a external hard drive that has been previously used to back up several pc 's, or is it best to have a separate external drive for the Mac?

    I would like to know if you have to back up a macbook hard drive, can I use a external hard drive that has been previously used to back up several pc 's, or is it best to have a separate external drive for the Mac?

    In the Mac side of things, backups usually come in two flavors: clones or incrementals.
    A bootable clone is a bit-for-bit copy of all essential files in the startup volume. If using the Lions, clones can be made using CarbonCopyCloner or just plain old Disk Utility. These backups represent the safest protection of your info, but take the longest to do. Recovery is an inverse process: you copy the clone back into the internal drive.
    Incremental backups start with a complete backup of the startup volume and only copy whatever changed from the previous run. OS X includes the fully integrated Time Machine backup utility to do this. It is extremely easy to do and takes the least amount of time. Recovery is another matter altogether since you have to start with a freshly installed instance of the OS and have to apply all intervening backups to bring the result to the latest saved version.
    As for where the backup takes place, the recommended media is an external dedicated drive or drives connected via the fastest interface available on your Mac: Thunderbolt, USB3, Firewire, or USB2. Network-based backups, wired or wireless, are attractive but may not offer the same performance and hence take longer. Also important to note that the entire drive need not be completely dedicated to a single backup. The Mac's EFI firmware infrastructure allows for an unlimited number of partitions on a hard drive and each can be used for either type of backups.
    Holler if you need specifics on how to do each. This was just an executive summary.

  • How can I save music that has been sent to me via email on my iPad.?

    How can I save music to my iPad that has been sent to me in an email? Please help

    You can't save it to the Music app directly on the iPad, you will need to see if there are any third-party music apps in the store that you allow you to copy music from Mail to them. For the Music app then only way to get music into it is via the iTunes store app directly on the iPad and by syncing from your computer's iTunes.

  • How to unlock macbook pro that has been remote locked from the icloud

    how do you unlock the macbook pro that has been remotly locked from the icloud because i forgot my password

    This question should NOT be answered. Using Find My Mac to lock one's computer is a personal security measure for those whose Macs have been lost or stolen and may be in the hands of criminals. Publicly posting instructions for defeating that measure would be tantamount to abetting theft.
    If you have foolishly locked your own computer and need to unlock it, take it to an Apple Store. Be prepared to prove you are its rightful owner.

  • How can i see history that has been deleted?

    I know that some history has been deleted and sometimes there is a web site that i went on and would like to see again but i cant because the history has been deleted.....how can i see what has been deleted?

    Terabyte wrote:
    If you sync your device to a Windows or MAC PC, then simply syncing you device again should restore the application from the backup folder on the PC.
    Huh?
    Strange, when I delete an application from any of my Palm devices, it stays deleted and has never returned!  
    If the OP is referring to Docs To Go, there is an option to reinstall the handheld programs available in the Desktop version of Docs To Go.
    Should be found up in the Tools or Options section (I'm on a computer that doesn't have it installed right now..)
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • How to recover safari history that has been cleared

    I have a 2012 iMac running Mavericks OSX 10.9.4 4GB 1333 MHZ
    I frequent a social network site that hosts photos, private mail conversations and blog discussions.
    I use an app " safari cache explorer" that will very quickly look at the cache files from the browser history and give me the option to view the line items as plain text, web page, or image. The plain text view is not really that readable so I would like any suggestion on how to convert that part to something more useful. The items that can be viewed as web pages are perfect and appear exactly as the did when I was on that webpage.
    Here is my problem. If the clear history function has been used in safari that explorer app has nothing to look at and sometimes I need to go back and find a preveiously viewed webpage. I am using time machine to backup to a Seagate backup plus drive and I have read at least several online discussions as well as everything on this community board on how to recover to recover to recover those files. There have been several  highly detailed explinations on how to accomplish this task but not one has worked.
    Is it possible to retrive the history.plist, cache plist or whatever is needed to see those web pages from a week or two ago in a manner that they are usable?
    If so what are the exact instructions on doing this task. A procedure that actually works would be much appreciated.
    Thanks in advance

    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Safari/History.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item selected. Quit the application if it's running. Enter Time Machine and restore the selected item from a snapshot that predates the unwanted changes. Relaunch the application and test.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • How do I unlock 4S that has been upgraded to iOS 7. Entered passcode does not work

    How do I unlock 4S I phone that has just been upgraded to iOS 7? The submitted code does not work.

    See here: http://support.apple.com/kb/HT1212

  • Deleting the spool files that has been generated

    Hi all, currently Im facing a problem when spool files are generated after executing a report program in background. I actually need the spool files to be deleted as soon as the printing has been completed and not to remain in the sp02 transation. The real issue is with the number of spool requests that remain in the sp02 when large number of files are be printed. Need your suggestion to delete the spools that got accumulated as soon as the printing is completed.

    Fill the print parameters RELEASE "Delete immediately after printing" (see [GET_PRINT_PARAMETERS|http://help.sap.com/abapdocu_70/en/ABENPRINT_PARAMETERS_FUNCTION.htm] and [Overview of All Print Parameters |http://help.sap.com/abapdocu_70/en/ABENPRINT_PARAMETERS_OVERVIEW.htm])
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
         EXPORTING
              no_dialog = 'X'
              release   = 'X'.
    Regards,
    Raymond

  • How to read xml file that has changing element names?

    Idon't know much about xml, nor reading it with java, but I have this problem with reading xml file. The file something like this:
    <configuration>
       <DEV001>
          <serial>001</serial>
          <id>number 1</id>
       </DEV001>
       <DEV002>
          <serial>002</serial>
          <id>number 2</id>
       </DEV002>
    </configuration>I have imported the org.w3c.dom.* api, that I use for parsing. I don't know is this a generic or a parser specific issue, but how can I get all the nodes starting with "DEV" into a NodeList?
    If you know a solution for this with another parser, please share it. I have no reason to use that specific parser, I just found a sample using that.
    kari-matti

    Well, NodeList is an interface, so you cannot construct one and put the "good" elements into it. But, you might be able to cast the NodeList with all of the children of the root into an IIOMetadaNode (which is the class that implements the NodeList interface. That class has a removeChild() method that might be able to remove the text nodes and any that don't start with DEV.
    But, if you remove nodes, and still want to do things with the full DOM Document, be very careful and run tests. It may remove those nodes from the full Document.
    If, on the other hand, the printingData( Nodelist nl) method could be modified so it takes an ArrayList or some other collection, it is very simple.
    Just create an ArrayList, and when you find an element starting with DEV, add it to the ArrayList. When you are done, process that list and you are finished.
    Dave Patterson

  • How do you remove contacts that has been copied to the SIM Card on Q10?

    I copied them and now I want to delete them  how do I do it? Plus it does not should how much space is on it?

    Within the Contacts app filter your list to  just show Sim entries, the tab on the left.
    Hold down your finger on the contact and a side menu will appear on the right at the bottom click on the trash can to delete that entry.
    If you've been helped click on , if you've been saved buy the app.
    Developer of stokLocker, Sympatico and Super Sentences.

  • How to remove a device that has been sold from iCloud Drive

    I sold my iPhone 5, yet it still appears in iCloud Drive. Have been unable to find a way to delete using iTune, MBPR or iPhone 6 Plus.

    If you mean that it still appears on the list of devices on iCloud.com when you click on your name and choose iCloud Preferences, you can't remove it yourself.  Another poster said that Apple support told him that it is supposed to be automatically removed when the new owner uses it to sign into a different iCloud account.

  • How to "Favourite" a Photo that has Been IMPORTED INTO THE PHONE?

    Hi,
    I recently switched from iPhone 5 to iPhone 5s. Using iPhoto and Image Capture on my Mac, I saved all the photos into a Mac folder. Then, I used iTunes to import these photos into my new phone. However, I have noticed that the little heart/favourite iconic my photos does not appear on the old photos, however, it does appear on the new photos. How do I fix this? Also, is there a way to backup photos to iCloud so that I can import them into a new phone without much hassle?
    - Sandy Wood

    This isn't working for me. I can't drag another one either. I've tried restarting to no avail...any ideas?

Maybe you are looking for

  • Solaris on an Intel chip

    Hello, I am considering migrating to Solaris10, but as of yet the only 64 bit versions I have seen run on AMD's and Intel Xeon's. I have an Intel 2.8Ghz DuoCore chip on a GigaByte MB which has an Intel 975 chip set and I have not been able to figure

  • Packet Loss Causing Game Lag

    For the past few days I've been experiencing severe lag while playing an online game.  The ping is normal, but the game stops responding or its response is delayed to such an extent that it's impossible to continue playing.  My friend attributed the

  • Need help w/ iTunes + Quicktime

    I just recently downloaded the new version of iTunes (without any success) and now I can't access iTunes or Quicktime. I am also having trouble uninstalling Quicktime from my computer. Here's what I have done, so far. 1)I have uninstalled iTunes 2) I

  • Motion 2.1 & Genarts Sapphire Plug ins

    These beautiful plug ins now seem to be incompatible with Motion 2.1 (UB). After emailing Genarts they say its how Apple has re written Motion and that it will no longer support AE plug ins! Has Apple gone mad!? Does anyone else have any information

  • Why javax.servlet.http.HttpServlet is serializable ?

    As per serialization definition if super class implements java.io.Serializable then all sub classes are also get that behaviour. while coming to Servlets : javax.servlet.GenericServlet implents java.io.Serializable and this servlet class is super cla