public NativeMessageHandler(bool throwOnCaptiveNetwork, bool customSSLVerification, NativeCookieHandler cookieHandler = null, SslProtocol? minimumSSLProtocol = null)
        {
            var configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration;

            // System.Net.ServicePointManager.SecurityProtocol provides a mechanism for specifying supported protocol types
            // for System.Net. Since iOS only provides an API for a minimum and maximum protocol we are not able to port
            // this configuration directly and instead use the specified minimum value when one is specified.
            if (minimumSSLProtocol.HasValue) {
                configuration.TLSMinimumSupportedProtocol = minimumSSLProtocol.Value;
            }

            session = NSUrlSession.FromConfiguration(
                NSUrlSessionConfiguration.DefaultSessionConfiguration, 
                new DataTaskDelegate(this), null);

            this.throwOnCaptiveNetwork = throwOnCaptiveNetwork;
            this.customSSLVerification = customSSLVerification;

            this.DisableCaching = false;
        }
        public NativeMessageHandler(bool throwOnCaptiveNetwork, bool customSSLVerification, NativeCookieHandler cookieHandler = null, SslProtocol? minimumSSLProtocol = null)
#endif
        {
            var configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration;

#if XAMARIN_MODERN
			// we cannot do a bitmask but we can set the minimum based on ServicePointManager.SecurityProtocol minimum
			var sp = ServicePointManager.SecurityProtocol;
			if ((sp & SecurityProtocolType.Ssl3) != 0)
				configuration.TLSMinimumSupportedProtocol = SslProtocol.Ssl_3_0;
			else if ((sp & SecurityProtocolType.Tls) != 0)
				configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_0;
			else if ((sp & SecurityProtocolType.Tls11) != 0)
				configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_1;
			else if ((sp & SecurityProtocolType.Tls12) != 0)
				configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_2;
#else
            // System.Net.ServicePointManager.SecurityProtocol provides a mechanism for specifying supported protocol types
            // for System.Net. Since iOS only provides an API for a minimum and maximum protocol we are not able to port
            // this configuration directly and instead use the specified minimum value when one is specified.
            if (minimumSSLProtocol.HasValue) {
                configuration.TLSMinimumSupportedProtocol = minimumSSLProtocol.Value;
            }
#endif

            session = NSUrlSession.FromConfiguration(
                NSUrlSessionConfiguration.DefaultSessionConfiguration, 
                new DataTaskDelegate(this), null);

#if !XAMARIN_MODERN
            this.throwOnCaptiveNetwork = throwOnCaptiveNetwork;
            this.customSSLVerification = customSSLVerification;
#else
            this.AllowAutoRedirect = true;
#endif

            this.DisableCaching = false;
        }
 public void SetTlsMinVersion(SslProtocol protocol) => sec_protocol_options_set_tls_min_version(GetCheckedHandle(), protocol);
 static extern void sec_protocol_options_set_tls_min_version(sec_protocol_options_t handle, SslProtocol protocol);
Example #5
0
 extern static /* OSStatus */ SslStatus SSLGetNegotiatedProtocolVersion(/* SSLContextRef */ IntPtr context, out SslProtocol protocol);
Example #6
0
 extern static /* OSStatus */ SslStatus SSLSetProtocolVersionMin(/* SSLContextRef */ IntPtr context, SslProtocol minVersion);
Example #7
0
 extern static /* OSStatus */ SslStatus SSLGetProtocolVersionMax(/* SSLContextRef */ IntPtr context, out SslProtocol maxVersion);
Example #8
0
 /// <summary>
 ///     Sets the SSL protocol for the device.
 /// </summary>
 /// <param name="protocol"></param>
 /// <returns></returns>
 public async Task SetSslProtocolAsync(SslProtocol protocol)
 {
     await ExecuteAtCommandAsync(new SslProtocolCommand(protocol));
 }
Example #9
0
 public SslProtocolCommand(SslProtocol protocol)
 {
     Parameter = protocol;
 }
Example #10
0
 static extern SslStatus SSLSetProtocolVersionMin(/* SSLContextRef */ IntPtr context, SslProtocol minVersion);
Example #11
0
 static extern SslStatus SSLGetProtocolVersionMax(/* SSLContextRef */ IntPtr context, out SslProtocol maxVersion);
Example #12
0
 static extern SslStatus SSLGetNegotiatedProtocolVersion(/* SSLContextRef */ IntPtr context, out SslProtocol protocol);
Example #13
0
 static TlsProtocols GetProtocol(SslProtocol protocol)
 {
     switch (protocol) {
     case SslProtocol.Tls_1_0:
         return TlsProtocols.Tls10;
     case SslProtocol.Tls_1_1:
         return TlsProtocols.Tls11;
     case SslProtocol.Tls_1_2:
         return TlsProtocols.Tls12;
     default:
         throw new NotSupportedException ();
     }
 }
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param>
 /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param>
 /// <param name="formatProvider">not used by this TypeConverter.</param>
 /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param>
 /// <returns>
 /// an instance of <see cref="SslProtocol" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => SslProtocol.CreateFrom(sourceValue);