Srodne teme
09.06.2006. SSL
18.11.2002. Network administrator
29.11.2002. MOUS-certificate
02.06.2003. Problem sa HTTPS na WinXP
09.01.2005. Psi 0.9
03.07.2003. get private key problem
02.03.2006. Zvucnici 5.1 veliki problem!!
Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

certificate problem

[es] :: Java :: certificate problem

[ Pregleda: 1896 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Shimmy
Miroslav Rankovic
Hermes SoftLab
Obrenovac

Član broj: 1175
Poruke: 7
*.hermes.si

ICQ: 17423796


Profil

icon certificate problem03.07.2003. u 16:39 - pre 224 meseci
Imam ovaj deo koda koji mi nalazi sertifikat u Mozillinom key storage-u.
Koristim funkciju findCertByIssuerAndSerialNumber(byte[] arg0, INTEGER arg1)kojoj treba da prosedim
DER enkodovan parametar issuer name kao niz bajtova i certificate serial number koji je tipa INTEGER.
Evo tog dela koda.

try
{
CryptoManager manager = CryptoManager.getInstance();
CryptoToken acToken = manager.getTokenByName("Internal Key Storage Token");
System.out.println("IsLoggedIn " + acToken.isLoggedIn());
manager.setThreadToken(acToken);

CryptoStore store = acToken.getCryptoStore();
org.mozilla.jss.crypto.X509Certificate[] certArr = store.getCertificates();

byte[] derCert = certArr[0].getEncoded();
Certificate certe = (Certificate) ASN1Util.decode(Certificate.getTemplate(), derCert);
Name issuerName = certe.getInfo().getIssuer();
byte[] derIssuer = ASN1Util.encode(issuerName);
byte[] derSerial = certArr[0].getSerialNumber().toByteArray();
INTEGER intSN = new INTEGER(derSerial);


org.mozilla.jss.crypto.X509Certificate javaCert = null;
javaCert = manager.findCertByIssuerAndSerialNumber(derIssuer, intSN);
}catch(Exception e){
System.out.println(e);
}
Ovo mi sve ok radi (makar mi se tako cini) ali problem nastaje kada da ocu da umesto Name varijable korisitm String varijablu u kojoj je upisan issuer info. Ne znam onda kako da iz String varijable dobijem taj DER enkodovan niz bajtova. U tom slucaju funkcija manager.findCertByIssuerAndSerialNumber(derIssuer, intSN) mi baca ObjectNotFoundException?!

Zna li neko kako bi to moglo da se uradi ? Nesto ovako bi hteo ali nikako da mi uspe. U pitanju je Java aplet.

public void start() {
try {
CryptoManager manager = CryptoManager.getInstance();
CryptoToken acToken = manager.getTokenByName("Internal Key Storage Token");
System.out.println("IsLoggedIn " + acToken.isLoggedIn());
manager.setThreadToken(acToken);

CryptoStore store = acToken.getCryptoStore();
org.mozilla.jss.crypto.X509Certificate[] certArr = store.getCertificates();

String issuerInfo = certArr[0].getIssuerDN().toString();
// sto sadrzi nesto ovako ... CN=CA2K, OU=SEB, O=ZASLON d.o.o., L=Beograd, ST=Vozdovac, C=SI, // [email protected]
String serialNumber = certArr[0].getSerialNumber().toString();

test(issuerInfo, serialNumber);

} catch (Exception e) {
System.out.println(e);
}
}


public void test(String issuerInfo, String serialNumber)
{
try
{
CryptoManager manager = CryptoManager.getInstance();
CryptoToken acToken = manager.getTokenByName("Internal Key Storage Token");
System.out.println("IsLoggedIn " + acToken.isLoggedIn());
manager.setThreadToken(acToken);

CryptoStore store = acToken.getCryptoStore();
org.mozilla.jss.crypto.X509Certificate[] certArr = store.getCertificates();

//kako dobiti sada OD issuerInfo DER enkodovan niz bajtova i da mi sve radi ok kao u prvom slucaju?

byte[] derIssuer = issuerInfo.GetBytes();
// ovo definitivno ne radi ... pa cak i kad mu prosledim u issuerInfo vec enkodovan podatak.

BigInteger bi = new BigInteger(serialNumber);
byte[] derSerial = bi.toByteArray();
INTEGER intSN = new INTEGER(derSerial);

org.mozilla.jss.crypto.X509Certificate javaCert = null;
//pri sledecem pozivu dobijem exception: ObjecyNotFound
javaCert = manager.findCertByIssuerAndSerialNumber(derIssuer, intSN);


}catch(Exception e){
System.out.println(e);
}
return res;
}

Zna li neko o cemu pricam i moze li mi pomoci ? :)

Best Regards,
Shimmy !
 
Odgovor na temu

[es] :: Java :: certificate problem

[ Pregleda: 1896 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Srodne teme
09.06.2006. SSL
18.11.2002. Network administrator
29.11.2002. MOUS-certificate
02.06.2003. Problem sa HTTPS na WinXP
09.01.2005. Psi 0.9
03.07.2003. get private key problem
02.03.2006. Zvucnici 5.1 veliki problem!!
Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.