Go Live Guide for Java SDK

Aug 19, 2008 at 2:03 PM
Edited Aug 19, 2008 at 2:04 PM
I am reading the go live information on the Developer center and I am not sure how to get my Java application setup. The application manager only seems to want pfx files and I can not figure out how to export the cert in that format from the keystore. A definitive guide to going live with the Java SDK would be really nice.
Aug 19, 2008 at 3:01 PM

I have similar problem. I create the cer file with application manager. Then I import it into keystore. But when i use it to make connection, SDK throws out an exception.

com.microsoft.hsg.HVException: com.microsoft.hsg.HVSystemException: Could not get private key information
 at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:69)
 at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:80)
 at com.microsoft.hsg.ApplicationAuthenticatorTest.testAuthenticate(ApplicationAuthenticatorTest.java:29)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
 at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
 at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
 at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
 at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
 at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
 at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
 at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.microsoft.hsg.HVSystemException: Could not get private key information
 at com.microsoft.hsg.DefaultPrivateKeyStore.initData(DefaultPrivateKeyStore.java:154)
 at com.microsoft.hsg.DefaultPrivateKeyStore.getPrivateKey(DefaultPrivateKeyStore.java:112)
 at com.microsoft.hsg.ApplicationAuthenticator.ensurePrivateKey(ApplicationAuthenticator.java:226)
 at com.microsoft.hsg.ApplicationAuthenticator.authenticate(ApplicationAuthenticator.java:137)
 at com.microsoft.hsg.ApplicationAuthenticator.authenticate(ApplicationAuthenticator.java:130)
 at com.microsoft.hsg.Connection.authenticate(Connection.java:159)
 at com.microsoft.hsg.Connection.authenticate(Connection.java:168)
 at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:63)
 ... 22 more
Caused by: com.microsoft.hsg.HVException: Key not found
 at com.microsoft.hsg.DefaultPrivateKeyStore.initData(DefaultPrivateKeyStore.java:140)
 ... 29 more

I think I didn't create the keystore properly. What's the right steps to generate the keystore from a cert?


Aug 19, 2008 at 5:23 PM
I think you need to use Java keytool to create and export certificate. Check this other thread How to Create a Certificate.

Aug 20, 2008 at 4:27 PM
Thanks but I have read the other forums and the keytool information and the keytool generates a .cer file which I am not able to import into the application manager.
Aug 20, 2008 at 4:42 PM
I just want to know how to get my Java SDK using application setup on the production environment. There seems to be conflicting documents and mostly centered around the .Net SDK which one document tells me to use the application manager which wants the cert in PFX format not the format that keytool exports. If that is even the correct path for the Java version I do not know.
Aug 20, 2008 at 6:12 PM
hi Ryan -

You can add the .cer file to your application from application configuration center if it already exists from the "Public Key" tab. Please note that in order for you to upload the application to our server (via applicaiton manager) you will have to create a PFX cert using the create certificate button and then right click on that cert and upload it. Once you do this you can actually associate the public key (.cer file) of your java private key using the "Public Key" tab of application configuration center.

Essentially you first create an app with a generated cert (pfx file) and then add the .cer file to this application.

Hope this helps.

Aug 21, 2008 at 7:33 PM
The .cer files are DER encoded X.509 certificates for the public key.  .pfx files contain both the private key and the public key.  The public key and needs to get into HealthVault's application repository.  The private key goes into the keystore.  The easiest way to get a private key into the keystore is to generate it there in the first place.  Then export the public key as the .cer file.  Generating a private key elsewhere and importing it into the keystore requires writing some custom code--not difficult, just not existing.  None of the keytool's commands support importing/exporting the private keys. 

So as vaibhav recommended, use the application manager to create your app in HealthVault initially.  The application manager wants a .pfx file because it places the private key into windows local key manager and registers your public key with HealthVault.  The first step is unnecessary for java applications but the tools show their origins.  Once your application is created in HealthVault, replace you public key stored with HealthVault with one generated with the keytool.  Protect the keystore and your private key, as it provides your access to HealthVault.