This commit is contained in:
@@ -71,15 +71,18 @@ public class ApnsService implements Service {
|
|||||||
final String path = "/" + this.getClass().getPackage().getName().replace('.', '/') + "/" + apnscertpath;
|
final String path = "/" + this.getClass().getPackage().getName().replace('.', '/') + "/" + apnscertpath;
|
||||||
KeyStore ks = KeyStore.getInstance("PKCS12");
|
KeyStore ks = KeyStore.getInstance("PKCS12");
|
||||||
InputStream in = ApnsService.class.getResourceAsStream(path);
|
InputStream in = ApnsService.class.getResourceAsStream(path);
|
||||||
ks.load(in, apnscertpwd.toCharArray());
|
KeyManagerFactory kf = null;
|
||||||
in.close();
|
if (in != null) {
|
||||||
KeyManagerFactory kf = KeyManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
ks.load(in, apnscertpwd.toCharArray());
|
||||||
kf.init(ks, apnscertpwd.toCharArray());
|
in.close();
|
||||||
|
kf = KeyManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
|
kf.init(ks, apnscertpwd.toCharArray());
|
||||||
|
}
|
||||||
|
|
||||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
tmf.init((KeyStore) null);
|
tmf.init((KeyStore) null);
|
||||||
SSLContext context = SSLContext.getInstance("TLS");
|
SSLContext context = SSLContext.getInstance("TLS");
|
||||||
context.init(kf.getKeyManagers(), tmf.getTrustManagers(), null);
|
context.init(kf == null ? new KeyManager[0] : kf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||||
ApnsService.this.sslFactory = context.getSocketFactory();
|
ApnsService.this.sslFactory = context.getSocketFactory();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.SEVERE, this.getClass().getSimpleName() + " init SSLContext error", e);
|
logger.log(Level.SEVERE, this.getClass().getSimpleName() + " init SSLContext error", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user