|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
SSL socket & Framework version support problemsHi Jeroen,
Sorry for the long post. Basically I'm writing a demo exe written in csharp which uses underlying java jars converted to dlls. I need to get SSL socket communications working. I've pure java code that loads keystore with certs and sets up SSL final String[] strEnabledProtocols_a = {"TLSv1"}; SSLSocketFactory factory; SSLContext ctx; KeyStore clientKeyStore, clientTrustStore; KeyManagerFactory kmf; TrustManagerFactory tmf; try { //Security.addProvider(new BouncyCastleProvider()); //Initialise factories and their KeyStore objects ctx = SSLContext.getInstance(strEnabl edProtocols_a[0]);
kmf = KeyManagerFactory.getInstance("SunX509"); tmf = TrustManagerFactory.getInstance("SunX509"); clientKeyStore = KeyStore.getInstance("pkcs12"); clientTrustStore = KeyStore.getInstance("JKS"); //Load TrusStore and KeyStore from file //Hard-coded password for decrypting Key Stores char[] passphrase = "whatEver".toCharArray(); // not real key ! clientKeyStore.load(new FileInputStream("E://projects//ClientPK_Cert.PKCS12"), passphrase); clientTrustStore.load(new FileInputStream("E://projects//CACert.JKS"), passphrase); //blows up here kmf.init(clientKeyStore, passphrase); //minimize password exposure passphrase = "".toCharArray(); tmf.init( clientTrustStore ); ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); factory = ctx.getSocketFactory(); //Socket commandSocket = factory.createSocket(inetAddress, commandPort); //((SSLSocket) commandSocket).setEnabledProtocols(strEnabledProtocols_a); } catch (NoSuchAlgorithmException e) { logger.log(Level.SEVERE, "NoSuchAlgorithmException", e); } catch (KeyStoreException e) { logger.log(Level.SEVERE, "KeyStoreException", e); } catch (CertificateException e) { logger.log(Level.SEVERE, "CertificateException", e); } catch (KeyManagementException e) { logger.log(Level.SEVERE, "KeyManagementException", e); } catch (UnrecoverableKeyException e) { logger.log(Level.SEVERE, "UnrecoverableKeyException", e); } catch (IOException e) { logger.log(Level.SEVERE, "IOException", e); } In a pure Java SE environment this code works but when I convert jar to dll and attempt to call this method it blows up with java.io.IOException: parseAlgParameters failed: PBE AlgorithmParameters not available at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:549) at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:128 0) at java.security.KeyStore.load(KeyStore.java:1204) ..... Caused by: java.security.NoSuchAlgorithmException: PBE AlgorithmParameters not available at sun.security.jca.GetInstance.getInstance(GetInstance.java:160) at java.security.Security.getImpl(Security.java:697) at java.security.AlgorithmParameters.getInstance(AlgorithmParameters.java:131) at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:542) I have tried putting into latest Bouncycastle provider jar and both statically and dynamically using BouncyCastleProvider. The same keystore issue arises. Any ideas? The deployment platform is Windows. The Jdk is Sun's 1.5.0_14 Secondly is Ikvm restricted to NDP 1.x only ? E:\temp\ikvm-0.36.0.11\bin>.\ikvmstub c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll Unhandled Exception: System.BadImageFormatException: The format of the file 'mscorlib.dll' is invalid. File name: "mscorlib.dll" at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence security Evidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm) at NetExp.Main(String[] args) === Pre-bind state information === LOG: Where-ref bind. Location = c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll LOG: Appbase = E:\temp\ikvm-0.36.0.11\bin\ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). === LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll. I then tried latest development snapshot E:\temp\0.37.2970\ikvm\bin>.\ikvmstub c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Method.java:625) at ikvm.internal.stubgen.RuntimeVisibleAnnotationsAttribute.WriteAnnotation(StubGenerator.java:1328) at ikvm.internal.stubgen.StubGenerator.writeAnnotations(StubGenerator.java:321) at IKVM.NativeCode.java.lang.Class.getRawAnnotations(Unknown Source) at java.lang.Class.initAnnotationsIfNecessary(Class.java:3091) at java.lang.Class.getDeclaredAnnotations(Class.java:3080) at ikvm.internal.stubgen.StubGenerator.run(StubGenerator.java:290) at ikvm.internal.stubgen.StubGenerator.run(StubGenerator.java:42) at IKVM.NativeCode.java.security.AccessController.doPrivileged(Unknown Source) at IKVM.NativeCode.java.security.AccessController.doPrivileged(Unknown Source) at ikvm.internal.stubgen.StubGenerator.generateStub(StubGenerator.java:54) at gnu.java.net.protocol.ikvmres.Handler.readResourceFromAssembly(Handler.java:155) at gnu.java.net.protocol.ikvmres.Handler.readResourceFromAssembly(Handler.java:131) at gnu.java.net.protocol.ikvmres.IkvmresURLConnection.connect(Handler.java:53) at gnu.java.net.protocol.ikvmres.IkvmresURLConnection.getInputStream(Handler.java:77) at java.net.URL.openStream(URL.java:1026) at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1179) at java.lang.Class.getResourceAsStream(Class.java:2048) at cli.NetExp.WriteClass(Unknown Source) at cli.NetExp.ProcessAssembly(Unknown Source) at cli.NetExp.Main(Unknown Source) Caused by: java.lang.ClassCastException at $Proxy0.value(Unknown Source) ... 21 more Warning: Assembly reflection encountered an error. Resultant JAR may be incomplete. Using all the features of DotNet2 such as generics and new classes such as SSLStream would be terrific. Thanks for the great product Paul ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
|
|
Re: SSL socket & Framework version support problemsP M wrote:
> In a pure Java SE environment this code works but when I convert jar to > dll and attempt to call this method it blows up with > > java.io.IOException: parseAlgParameters failed: PBE AlgorithmParameters > not available This most likely because parts of the security/crypto implementation are still based on GNU Classpath / IcedTea. There are some incompatibilities there. I hope to release an update at some point that includes more of the OpenJDK code in this area. > Secondly is Ikvm restricted to NDP 1.x only ? No, 2.0 is fully supported, but you have to run on 2.0 to be able to deal with 2.0 assemblies. If you create an app.config that forces ikvmstub.exe (or ikvm.exe or ikvmc.exe) to run on .NET 2.0 you'll be able to use 2.0 assemblies and features. The ikvmstub.exe.config should have: <?xml version="1.0"?> <configuration> <startup> <supportedRuntime version="v2.0.50727"/> <requiredRuntime version="v2.0.50727"/> </startup> </configuration> > I then tried latest development snapshot > > E:\temp\0.37.2970\ikvm\bin>.\ikvmstub > c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll > java.lang.reflect.InvocationTargetException Yes, this was a bug in that version. I don't really test development snapshots all that well (that's why they come with the warning and disclaimer). Regards, Jeroen ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
|
|
|
|
|
Re: SSL socket & Framework version support problemsP M wrote:
> Any idea when when this might happen? Lookjng at the openjdk builds it > would appear that b21 at least is required for 'better' SSL support. My current plan is to look at updating the OpenJDK after OpenJDK 1.6 is released. Regards, Jeroen ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
| Free Forum Powered by Nabble | Forum Help |