Self-signed security certificates.. (oh, the evil)

D

Darren

Dag Sunde said:
No, I mean: at the top of your source-code file, is there a line like this:
package no.orion.crossdomain;
Where no.orion.crossdomain' is the package name for my class.

Oh right, no i don't use one of those buti didn't think i would need to for
a single class.
When I refere to the class 'Crossdomain.class' in the applet or object
tag, i have to specify the package name as well, so the full name becomes:
'no.orion.crossdomain.Crossdomain.class'



The double use of object here is a trick Chris Head made up, since it
is only IE that recognize the 'classid=' attribute, so the other object
tag is for anything else that IE. (netscape, opera, FF...)

Ha I figures. Bloody browsers. :)
But for your simple applet, you don't need the complexity of the object
tag, so you should stick with the applet tag.

If you want, I can make an applet for you, that takes a server name and
a file name as parameters, and sign it for you, just as a test.

So you can try to put it on your server to see if it is you that do
anything wrong, or if it is something with your environment...
I would appreciate that very much. one thing i'm curious about. As my jar
file is secured and sighned then shouldn't my browser ask my permission to
use it?
 
D

Dag Sunde

Darren said:
Oh right, no i don't use one of those buti didn't think i would need to
for
a single class.

Ha I figures. Bloody browsers. :)
I would appreciate that very much. one thing i'm curious about. As my jar
file is secured and sighned then shouldn't my browser ask my permission to
use it?

Yes, it should!

BTW...
The MayScript attribute means that the Applet should be allowed to
access JavaScript code in the page that contains is.
The Scriptable attribute means that Javascript should be allowed to
call public methods in the Applet.

Ok...
I'll modify the CrossDomain Applet I made for testing, then I jar and sign
it
with my self-signed certificate.
Then I put up a sample html-file that uses it, and some kind of testfile to
put on your private server, so the applet have something well-known to ask
for.

I'll try to do it tonight...
 
D

Darren

Dag Sunde said:
Yes, it should!

BTW...
The MayScript attribute means that the Applet should be allowed to
access JavaScript code in the page that contains is.
The Scriptable attribute means that Javascript should be allowed to
call public methods in the Applet.

Ok...
I'll modify the CrossDomain Applet I made for testing, then I jar and sign
it
with my self-signed certificate.
Then I put up a sample html-file that uses it, and some kind of testfile to
put on your private server, so the applet have something well-known to ask
for.

I'll try to do it tonight...
Much appreciated. I wonder why my browser didn't aske permission. Do you
think it might be something to do with those last two steps on that page
posted by I can't remember who and my apologies to that poster for not
acknowledging you sooner. I read that the last to steps i didn't have to do.
 
D

Darren

I think the problem has something to do with the Jar file. It would load the
class file fine but when i stick it in a self signed jar then it throws a
wobbler. here's what i did


c:\j2sdk1.4.2_06\bin\keytool -genkey -keyalg rsa -alias dazkey
c:\j2sdk1.4.2_06\bin\keytool -export -alias dazkey -file dazsuncert.crt
c:\j2sdk1.4.2_06\bin\jar cvf c:\applets\Helloserver.jar
c:\applets\Helloserver.class
c:\j2sdk1.4.2_06\bin\jarsigner c:\applets\Helloserver.jar dazkey
c:\j2sdk1.4.2_06\bin\jarsigner -verify -verbose -certs
c:\applets\Helloserver.jar

This is what the java console reported
Java Plug-in 1.5.0_04
Using JRE version 1.5.0_04 Java HotSpot(TM) Client VM
User home directory = C:\WINDOWS


----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

load: class Helloserver.class not found.
java.lang.ClassNotFoundException: Helloserver.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-Helloserver.class"
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The source is below

import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import java.security.*;
import java.lang.*;

public class Helloserver extends Applet
{
private String hostname = "http://g7wap.dyndns.org/";
private String protocol = "http://";
private String port="80";
private URL location;
private Object content;
private String tmpStr = "GET / HTTP / 1.1\r\n\r\n";//Accept:
*/*\r\n\r\n";//Accept-Language: en-gb\r\n\r\nXXXXXXXXXXXXXXX:
XXXXXXXXXXXXX\r\n\r\nUser-Agent: HelloServer 1\r\n\r\n";
private byte[] getStr = tmpStr.getBytes();



public void init()
{


hello();
}

public void paint(Graphics g)
{

g.drawString(hostname, 50, 60 );
}

/**
* Method hello
*
*
* @return
*
*/
protected boolean hello()
{
String str,buf,server;
byte[] ba = new byte[1024];
int bytesRead;
Socket socket=new Socket();


buf="";


try
{
// O P E N
socket = new Socket();
socket.setSoTimeout(3000);
SocketPermission p1 = new SocketPermission("10.0.0.254:80",
"connect,accept,resolve");
socket.connect(new InetSocketAddress("10.0.0.254", 80),3000 );
}
catch(AccessControlException u)
{
System.err.println(u.getMessage());
}
catch(MalformedURLException u)
{
buf=u.getMessage();
}
catch (UnknownHostException u)
{
return false;
}

catch(SocketTimeoutException u)
{
return false;
}
catch(IOException u)
{

}
try
{

InputStream is = socket.getInputStream();
socket.setSoTimeout(3000);
try
{

OutputStream os= socket.getOutputStream();
try
{
os.write(getStr,0,tmpStr.length());
}
catch(IOException u)
{

}



}
catch(IOException u)
{

}



// R E A D


bytesRead = is.read( ba, 0 /* offset in ba */, ba.length /* bytes to read
*/ );
if (bytesRead!=-1)
{

System.out.println(bytesRead);
buf=new String(ba);
System.out.println(buf);
is.close();
}
}
catch(IOException u)
{

}



// C L O S E
try
{

socket.close();
}
catch(IOException u)
{

}







return true;
}


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top