This commit is contained in:
@@ -54,23 +54,33 @@ public class ApnsService implements Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(AnyValue conf) {
|
public void init(AnyValue conf) {
|
||||||
try {
|
new Thread() {
|
||||||
final String path = "/" + this.getClass().getPackage().getName().replace('.', '/') + "/" + apnscertpath;
|
{
|
||||||
KeyStore ks = KeyStore.getInstance("PKCS12");
|
setDaemon(true);
|
||||||
InputStream in = ApnsService.class.getResourceAsStream(path);
|
setPriority(Thread.MAX_PRIORITY);
|
||||||
ks.load(in, apnscertpwd.toCharArray());
|
}
|
||||||
in.close();
|
|
||||||
KeyManagerFactory kf = KeyManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
|
||||||
kf.init(ks, apnscertpwd.toCharArray());
|
|
||||||
|
|
||||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
@Override
|
||||||
tmf.init((KeyStore) null);
|
public void run() {
|
||||||
SSLContext context = SSLContext.getInstance("TLS");
|
try {
|
||||||
context.init(kf.getKeyManagers(), tmf.getTrustManagers(), null);
|
final String path = "/" + this.getClass().getPackage().getName().replace('.', '/') + "/" + apnscertpath;
|
||||||
this.sslFactory = context.getSocketFactory();
|
KeyStore ks = KeyStore.getInstance("PKCS12");
|
||||||
} catch (Exception e) {
|
InputStream in = ApnsService.class.getResourceAsStream(path);
|
||||||
logger.log(Level.SEVERE, this.getClass().getSimpleName() + " init SSLContext error", e);
|
ks.load(in, apnscertpwd.toCharArray());
|
||||||
}
|
in.close();
|
||||||
|
KeyManagerFactory kf = KeyManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
|
kf.init(ks, apnscertpwd.toCharArray());
|
||||||
|
|
||||||
|
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
|
tmf.init((KeyStore) null);
|
||||||
|
SSLContext context = SSLContext.getInstance("TLS");
|
||||||
|
context.init(kf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||||
|
ApnsService.this.sslFactory = context.getSocketFactory();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.log(Level.SEVERE, this.getClass().getSimpleName() + " init SSLContext error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user