22 Mart 2018 Perşembe

TrustManagerFactory Sınıfı

Giriş
Şu satırı dahil ederiz.
import javax.net.ssl.TrustManagerFactory;
getDefaultAlgorithm metodu
Şöyle yaparız
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
getInstance metodu
Vendor specific başka kodlar olabilir. getDefaultAlgorithm() ile PKIX (Public Key Infrastructure X.509) olanı alırız. Açıklaması şöyle.
SunX509: A factory for X509ExtendedTrustManager instances that validate certificate chains according to the rules defined by the IETF PKIX working group in RFC 3280 or its successor. This TrustManagerFactory supports initialization using a Keystore object, but does not currently support initialization using the class javax.net.ssl.ManagerFactoryParameters.
PKIX: A factory for X509ExtendedTrustManager instances that validate certificate chains according to the rules defined by the IETF PKIX working group in RFC 3280 or its successor. This TrustManagerFactory currently supports initialization using a KeyStore object or javax.net.ssl.CertPathTrustManagerParameters.
Şöyle yaparız.
TrustManagerFactory tmf = TrustManagerFactory
            .getInstance(TrustManagerFactory.getDefaultAlgorithm());
getTrustManagers metodu
Örnek
TrustManager arayüzü dizisi döner. Şöyle yaparız.
 TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
Örnek
Şöyle yaparız.
SSLContext sslContext = ...;
sslContext.init(null, tmf.getTrustManagers(), null);
init metodu
Şöyle yaparız.
KeyStore k = ...;
tmf.init(k);

Hiç yorum yok:

Yorum Gönder