Results 1 to 2 of 2
Thread: How to post HTTPS request
- 07-29-2012, 11:37 AM #1
Member
- Join Date
- Jul 2012
- Posts
- 2
- Rep Power
- 0
How to post HTTPS request
Hi guys,
Im trying also to post https request, but unfortunately it doesn't work.
I creating a https server as follows:
protected void createServer() throws IOException {
InetSocketAddress address = new InetSocketAddress(this.host, this.port);
this.requestHandler = new HttpsRequestsHandler();
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
SSLContext ssl = null;
// Install the all-trusting trust manager
try {
char[] KEYSTOREPW = "serverkspw".toCharArray(); //username
char[] KEYPW = "serverpw".toCharArray(); //password
String KEYSTORE = "certs";
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(new FileInputStream("c://"+ KEYSTORE), KEYSTOREPW);
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keystore, KEYPW);
ssl = SSLContext.getInstance("SSLv3");
ssl.init(kmf.getKeyManagers(), null, null);
HttpsURLConnection.setDefaultSSLSocketFactory(ssl. getSocketFactory());
} catch (Exception e) {
}
try {
HttpsServer newServer = HttpsServer.create(address,10);
newServer.setHttpsConfigurator (new HttpsConfigurator(ssl) {
public void configure (HttpsParameters params) {
SSLContext c = getSSLContext();
// get the default parameters
SSLParameters sslparams = c.getDefaultSSLParameters();
params.setSSLParameters(sslparams);
}
});
Somebody please can tell me where i'm wrong? what i need to change?
Thanks a lot!
Dror.
- 07-29-2012, 01:34 PM #2
Re: How to post HTTPS request
Removed from How to post HTTPS request from java client to server . Don't post to old dead threads. That thread was five years old.
Please go through all these:
Forum Rules
Guide For New Members
BB Code List - Java Programming Forum
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Https post
By dongorangoran in forum NetworkingReplies: 1Last Post: 02-21-2011, 03:11 PM -
HTTPS POST Using Java
By drcman in forum Advanced JavaReplies: 7Last Post: 02-13-2010, 02:19 PM -
How redirect a request to https
By vns955 in forum Web FrameworksReplies: 1Last Post: 11-12-2009, 03:26 AM -
First post as per request
By happyknappy in forum IntroductionsReplies: 3Last Post: 07-30-2008, 01:33 AM -
How to post HTTPS request from java client to server
By Desai in forum NetworkingReplies: 1Last Post: 07-14-2007, 05:15 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks