Hi,
I used "feedback.sandbox.push.apple.com" to test my Feedback Service, but just get nothing returned. Is there anyone who get something returned ?
My code is below. It really confuses me.
/******* Here build a sslConnection to get feedback **************/
try {
String certPath ="**********_dev_key.p12";
KeyStore keyStore = KeyStore.getInstance("PKCS12");
String devPass = "ihandysoft";
String host ="feedback.sandbox.push.apple.com";
//host="feedback.push.apple.com";
int port = 2196;
keyStore.load(new FileInputStream(certPath), devPass.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keyStore, devPass.toCharArray());
TrustManager[] tms = new TrustManager[]{new ServerTrustingTrustManager() };
//tms[0]= new ServerTrustingTrustManager();
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(), tms, null);
SSLSocketFactory factory = sslContext.getSocketFactory();
SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
String [] suites = socket.getSupportedCipherSuites();
socket.setEnabledCipherSuites(suites);
socket.startHandshake();
InputStream is = socket.getInputStream();
byte[] a = new byte[100];
/*no return information here */
System.out.println ( is.available() );
}catch(Exception e) {
e.printStackTrace();
}
/**** overriide X509TrustManager : ServerTrustingTrustManager.java****/
public class ServerTrustingTrustManager implements X509TrustManager {
public void checkClientTrusted( X509Certificate[] chain, String authType ) throws CertificateException {
throw new CertificateException( "Client is not trusted." );
}
public void checkServerTrusted( X509Certificate[] chain, String authType ) {
// trust all servers
}
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[0];
}
public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
String authType) throws CertificateException {
// TODO Auto-generated method stub
}
public void checkServerTrusted(java.security.cert.X509Certificate[] chain,
String authType) throws CertificateException {
// TODO Auto-generated method stub
}
}