Hello all,
I have an web application that conect with https and request a client certification.
i get the client certificate from the request:
X509Certificate[] certs = (X509Certificate[])request.getAttribute("javax.servlet.request.X509Certificate");
X509Certificate cert = certs[0];
String dn = cert.getSubjectDN().getName();
this string: "CÚsar Fernßndez"
i want the string that appears well in the Internet Explorer is: "César Fernández" (name with accents)
i intent:
byte[] value = dn.getBytes();
String dnS = new String(value, "ISO-8859-1");
but it don't works.
thanks in advance,
César.
-
X509Certificate encoding (3 messages)
- Posted by: C?sar Fern?ndez
- Posted on: April 13 2004 08:43 EDT
Threaded Messages (3)
- X509Certificate encoding by Mircea Crisan on April 13 2004 09:47 EDT
- X509Certificate encoding by Cesar Fernandez Garcia on April 14 2004 02:41 EDT
- Small advice by Stas Sakalou on April 21 2004 01:50 EDT
- X509Certificate encoding by Cesar Fernandez Garcia on April 14 2004 02:41 EDT
-
X509Certificate encoding[ Go to top ]
- Posted by: Mircea Crisan
- Posted on: April 13 2004 09:47 EDT
- in response to C?sar Fern?ndez
Hi,
Don't know if if works but try this:
X509Certificate[] certs = (X509Certificate[])request.getAttribute("javax.servlet.request.X509Certificate");
X509Certificate cert = certs[0];
X500Principal principal = (X500Principal) cert.getSubjectDN();
String dn = principal.getName(X500Principal.CANONICAL);
or
String dn = principal.getName(X500Principal.RFC1779);
Best regards, Mircea -
X509Certificate encoding[ Go to top ]
- Posted by: Cesar Fernandez Garcia
- Posted on: April 14 2004 02:41 EDT
- in response to Mircea Crisan
Hello,
it thinks that don't works, thanks anyway.
César. -
Small advice[ Go to top ]
- Posted by: Stas Sakalou
- Posted on: April 21 2004 13:50 EDT
- in response to Cesar Fernandez Garcia
I am not good in encryption but I got this example
from the sun security forum and this example works prity good.
import java.security.Security;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyFactory;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import sun.misc.BASE64Encoder;
import java.security.spec.X509EncodedKeySpec;
import org.bouncycastle.util.encoders.Base64;
import java.io.*;
...
//Restore Keys from the File
KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
BufferedReader br = new BufferedReader(new FileReader(fileName));
StringBuffer keyBase64 = new StringBuffer();
String line = br.readLine ();
Key key = null;
while(line != null)
{
keyBase64.append (line);
line = br.readLine ();
}
byte [] bytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());