Udostępnij za pośrednictwem


SSLSocketFactory Class

Definition

Layered socket factory for TLS/SSL connections, based on JSSE.

[Android.Runtime.Register("org/apache/http/conn/ssl/SSLSocketFactory", DoNotGenerateAcw=true)]
public class SSLSocketFactory : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Org.Apache.Http.Conn.Schemes.ILayeredSocketFactory
[<Android.Runtime.Register("org/apache/http/conn/ssl/SSLSocketFactory", DoNotGenerateAcw=true)>]
type SSLSocketFactory = class
    inherit Object
    interface ILayeredSocketFactory
    interface ISocketFactory
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
SSLSocketFactory
Attributes
Implements

Remarks

Layered socket factory for TLS/SSL connections, based on JSSE. .

SSLSocketFactory can be used to validate the identity of the HTTPS server against a list of trusted certificates and to authenticate to the HTTPS server using a private key.

SSLSocketFactory will enable server authentication when supplied with a KeyStore truststore file containg one or several trusted certificates. The client secure socket will reject the connection during the SSL session handshake if the target HTTPS server attempts to authenticate itself with a non-trusted certificate.

Use JDK keytool utility to import a trusted certificate and generate a truststore file:

keytool -import -alias "my server cert" -file server.crt -keystore my.truststore

</p>

SSLSocketFactory will enable client authentication when supplied with a KeyStore keystore file containg a private key/public certificate pair. The client secure socket will use the private key to authenticate itself to the target HTTPS server during the SSL session handshake if requested to do so by the server. The target HTTPS server will in its turn verify the certificate presented by the client in order to establish client's authenticity

Use the following sequence of actions to generate a keystore file

<ul> <li>

Use JDK keytool utility to generate a new key

keytool -genkey -v -alias "my client key" -validity 365 -keystore my.keystore

For simplicity use the same password for the key as that of the keystore </p> </li> <li>

Issue a certificate signing request (CSR)

keytool -certreq -alias "my client key" -file mycertreq.csr -keystore my.keystore

</p> </li> <li>

Send the certificate request to the trusted Certificate Authority for signature. One may choose to act as their own CA and sign the certificate request using a PKI tool, such as OpenSSL.

</li> <li>

Import the trusted CA root certificate

keytool -import -alias "my trusted ca" -file caroot.crt -keystore my.keystore

</p> </li> <li>

Import the PKCS#7 file containg the complete certificate chain

keytool -import -alias "my client key" -file mycert.p7 -keystore my.keystore

</p> </li> <li>

Verify the content the resultant keystore file

keytool -list -v -keystore my.keystore

</p> </li> </ul>

This member is deprecated. Please use java.net.URL#openConnection instead. Please visit this webpage for further details.

Java documentation for org.apache.http.conn.ssl.SSLSocketFactory.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

SSLSocketFactory(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

SSLSocketFactory(KeyStore, String, KeyStore)

Creates the default SSL socket factory.

SSLSocketFactory(KeyStore, String)

Creates the default SSL socket factory.

SSLSocketFactory(KeyStore)

Creates the default SSL socket factory.

SSLSocketFactory(String, KeyStore, String, KeyStore, SecureRandom, IHostNameResolver)

Creates the default SSL socket factory.

Fields

Ssl
Sslv2
Tls

Properties

AllowAllHostnameVerifier
BrowserCompatibleHostnameVerifier
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
HostnameVerifier
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
SocketFactory

Gets an singleton instance of the SSLProtocolSocketFactory.

StrictHostnameVerifier
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
ConnectSocket(Socket, String, Int32, InetAddress, Int32, IHttpParams)

Connects a socket to the given host.

ConnectSocketAsync(Socket, String, Int32, InetAddress, Int32, IHttpParams)
CreateSocket()

Creates a new, unconnected socket.

CreateSocket(Socket, String, Int32, Boolean)

Returns a socket connected to the given host that is layered over an existing socket.

CreateSocketAsync()
CreateSocketAsync(Socket, String, Int32, Boolean)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
IsSecure(Socket)

Checks whether a socket connection is secure.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
CreateSocketAsync(ILayeredSocketFactory, Socket, String, Int32, Boolean)
ConnectSocketAsync(ISocketFactory, Socket, String, Int32, InetAddress, Int32, IHttpParams)

Applies to