Hej igen,
Jeg har prøvet at kigge de to links igennem - men jeg har ikke kunnet finde
hjælp. Jeg prøver at poste min kode:
/********************************
public class Temp
{
String opslag = "27103235";
String user = "bruger";
String kode = "hemmeligt";
int level = 2;
LegalUnit unit = null;
CVRPortType port = null;
CVRBindingStub stub = null;
CVRWebServiceLocator cvr = null;
Service service = null;
public Temp()
{
try
{
System.setProperty("javax.net.debug", "all");
File file = new File("c:"+File.separatorChar+"onlinecvrdk.crt");
CertificateReader cert = new CertificateReader(file.toString());
// Create KeyStore to hold certificate from CVR
KeyStore keyStore = CertificateReader.createKeyStore();
// Create X509Certificate object from downloaded file with
certificate
X509Certificate x509certificate =
CertificateReader.getCertificate(file.toString());
// Check validity of certificate
//CertificateReader.checkCertificateValidity(x509certificate);
// Put X509Certificate in keyStore
keyStore.setCertificateEntry("MyCertificate", x509certificate);
// Get public key from MyCertificate via keyStore
PublicKey publicKey =
keyStore.getCertificate("MyCertificate").getPublicKey();
// Output publicKey to Console
SSLContext sslContext = SSLContext.getInstance("SSLv3");
TrustManagerFactory trustMgtFactory =
TrustManagerFactory.getInstance("SunX509");
trustMgtFactory.init(keyStore);
sslContext.init(null, trustMgtFactory.getTrustManagers(), null);
SSLSocketFactory sslSocketFactory =
sslContext.getSocketFactory();
HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
CVRWebServiceLocator cvr = new CVRWebServiceLocator();
URL cascadeURL = new URL(cvr.getCVRPortAddress());
CVRBindingStub stub = new CVRBindingStub(cascadeURL,cvr);
stub.setPassword(kode);
stub.setUsername(user);
/*
Det er denne linie der giver problemer
*/
LegalUnit unit = stub.getLegalUnit(user,kode,opslag,1);
} catch (KeyStoreException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
} catch (CertificateException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
} catch (NoSuchAlgorithmException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
} catch (KeyManagementException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
}
}
************************************************/
Problemet er at linien LegalUnit unit =
stub.getLegalUnit(user,kode,opslag,1); Jeg ved at der ligger et certifikat i
min keystore fordi jeg udskriver den hver gang jeg starter programmet
Men
er dr der noge helt fundamental jeg overser? Den URL der gives med til
stuben skal det være en som der er åbnet udfra HttpsURLConnection for at
associsere keystoren med https-addressen?