Compartir a través de


SSLCertificateSocketFactory Class

Definition

SSLSocketFactory implementation with several extra features:

        <ul>
        <li>Timeout specification for SSL handshake operations
        <li>Hostname verification in most cases (see WARNINGs below)
        &lt;li&gt;Optional SSL session caching with <code data-dev-comment-type="c">SSLSessionCache</code>&lt;li&gt;Optionally bypass all SSL certificate checks
        &lt;/ul&gt;

        The handshake timeout does not apply to actual TCP socket connection.
[Android.Runtime.Register("android/net/SSLCertificateSocketFactory", DoNotGenerateAcw=true)]
public class SSLCertificateSocketFactory : Javax.Net.Ssl.SSLSocketFactory
[<Android.Runtime.Register("android/net/SSLCertificateSocketFactory", DoNotGenerateAcw=true)>]
type SSLCertificateSocketFactory = class
    inherit SSLSocketFactory
Inheritance
SSLCertificateSocketFactory
Attributes

Remarks

SSLSocketFactory implementation with several extra features:

<ul> <li>Timeout specification for SSL handshake operations <li>Hostname verification in most cases (see WARNINGs below) <li>Optional SSL session caching with SSLSessionCache<li>Optionally bypass all SSL certificate checks </ul>

The handshake timeout does not apply to actual TCP socket connection. If you want a connection timeout as well, use #createSocket() and Socket#connect(java.net.SocketAddress, int), after which you must verify the identity of the server you are connected to.

<p class="caution"><b>Most SSLSocketFactory implementations do not verify the server's identity, allowing person-in-the-middle attacks.</b> This implementation does check the server's certificate hostname, but only for createSocket variants that specify a hostname. When using methods that use InetAddress or which return an unconnected socket, you MUST verify the server's identity yourself to ensure a secure connection.

Refer to Updating Your Security Provider to Protect Against SSL Exploits for further information.</p>

The recommended way to verify the server's identity is to use HttpsURLConnection#getDefaultHostnameVerifier() to get a HostnameVerifier to verify the certificate hostname.

<b>Warning</b>: Some methods on this class return connected sockets and some return unconnected sockets. For the methods that return connected sockets, setting connection- or handshake-related properties on those sockets will have no effect.

On development devices, "setprop socket.relaxsslcheck yes" bypasses all SSL certificate and hostname checks for testing purposes. This setting requires root access.

This member is deprecated. This class has less error-prone replacements using standard APIs. To create an SSLSocket, obtain an SSLSocketFactory from SSLSocketFactory#getDefault() or javax.net.ssl.SSLContext#getSocketFactory(). To verify hostnames, pass "HTTPS" to javax.net.ssl.SSLParameters#setEndpointIdentificationAlgorithm(String). To enable ALPN, use javax.net.ssl.SSLParameters#setApplicationProtocols(String[]). To enable SNI, use javax.net.ssl.SSLParameters#setServerNames(java.util.List).

Java documentation for android.net.SSLCertificateSocketFactory.

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

SSLCertificateSocketFactory(Int32)
Obsolete.

This member is deprecated.

SSLCertificateSocketFactory(IntPtr, JniHandleOwnership)

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

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
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)
CreateSocket()

Creates an unconnected socket.

(Inherited from SocketFactory)
CreateSocket(InetAddress, Int32, InetAddress, Int32)
Obsolete.

To be added

CreateSocket(InetAddress, Int32)
Obsolete.

To be added

CreateSocket(Socket, String, Int32, Boolean)
Obsolete.

To be added

CreateSocket(String, Int32, InetAddress, Int32)
Obsolete.

To be added

CreateSocket(String, Int32)
Obsolete.

To be added

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

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

(Inherited from Object)
GetDefault(Int32, SSLSessionCache)

Returns a new socket factory instance with an optional handshake timeout and SSL session cache.

GetDefault(Int32)

Returns a new socket factory instance with an optional handshake timeout.

GetDefaultCipherSuites()
Obsolete.

Returns the names of the cipher suites that are enabled by default.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetHttpSocketFactory(Int32, SSLSessionCache)

Returns a socket factory (also named SSLSocketFactory, but in a different namespace) for use with the Apache HTTP stack.

GetInsecure(Int32, SSLSessionCache)

Returns a new instance of a socket factory with all SSL security checks disabled, using an optional handshake timeout and SSL session cache.

GetNpnSelectedProtocol(Socket)

Returns the Next Protocol Negotiation (NPN) protocol selected by client and server, or null if no protocol was negotiated.

GetSupportedCipherSuites()
Obsolete.

Returns the names of the cipher suites that are supported and could be enabled for an SSL connection.

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)
SetHostname(Socket, String)

Turns on Server Name Indication (SNI) on a given socket.

SetKeyManagers(IKeyManager[])

Sets the KeyManagers to be used for connections made by this factory.

SetNpnProtocols(Byte[][])

Sets the Next Protocol Negotiation (NPN) protocols that this peer is interested in.

SetTrustManagers(ITrustManager[])

Sets the TrustManagers to be used for connections made by this factory.

SetUseSessionTickets(Socket, Boolean)

Enables session ticket support on the given socket.

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)

Applies to