Since we're not able to ship Openssl w/ Android, we need to implement as much as we can with the Android API's.
Implementation
System.Security.Cryptogaphy
System.Net.Security
Not supported
The following are not supported on Android. They should be documented, marked with UnsupportedOSPlatform, and/or throw PlatformNotSupportedException as appropriate.
System.Security.Cryptogaphy
System.Net.Security
Future improvements
The following should be considered after the initial implementation. If it is determined they are desired, they can be split into their own issues.
System.Security.Cryptogaphy
System.Net.Security
Clean-up
Other
Since we're not able to ship Openssl w/ Android, we need to implement as much as we can with the Android API's.
Implementation
-avd <emulatorName> -memory 3072 -wipe-data -delay-adb -skip-adb-auth -no-boot-anim -no-window -no-audio -gpu swiftshader_indirect -logcat-output '/tmp/<emulatorName>-logcat.log'System.Security.Cryptogaphy
System.Net.Security
HttpClientsetsApplicationProtocolsonly if intending to use HTTP/2+CipherSuitesPolicythrows PNSE on Windows, so this is nice to have, but not criticalRemoteCertRequired) - [AndroidCrypto] Handle setting non-default application protocols #51187SslStreamPal.QueryContextChannelBinding- [AndroidCrypto] Fix handling of no peer certificates #51316CertificateValidationPal.GetRequestCertificateAuthoritiesNot supported
The following are not supported on Android. They should be documented, marked with
UnsupportedOSPlatform, and/or throwPlatformNotSupportedExceptionas appropriate.System.Security.Cryptogaphy
RC2algorithmCreateDecryptorandCreateEncryptorcurrently throw PNSE,Createdoes notIncrementalHash.GetCurrentHashusing HMACAllowUnknownCertificateAuthority,IgnoreInvalidName,IgnoreInvalidPolicy,IgnoreTimeNotValidX509Chain.Buildwill return false and havePartialChainstatus with no certificatesX509RevocationMode:Offlinetreated asOnlineX509RevocationFlag:EntireChaintreated asExcludeRootPKIXRevocationChecker(API level <24)System.Net.Security
Any- resolved in .NET 8RemoteCertificateValidationCallbackwill only get an opportunity to validate certificates that have already been accepted by the system's built-in trust manager.This means that the use cases of the callback for self-signed certificates or custom trust will not work.- resolved in .NET 8EncryptionPolicy.NoEncryption(onSslClientAuthenticationOptions.EncryptionPolicyorSslServerAuthenticationOptions.EncryptionPolicy)HttpClientHandler.SslProtocols,SslClientAuthenticationOptions.EnabledSslProtocols, orSslServerAuthenticationOptions.EnabledSslProtocols):SslProtocols.Ssl2- not supportedSslProtocols.Ssl3- not supportedSslProtocols.Tls13- only on some versions of Android (>= API level 29)SslClientAuthenticationOptions.TargetHost)Future improvements
The following should be considered after the initial implementation. If it is determined they are desired, they can be split into their own issues.
CryptographicException.System.Security.Cryptogaphy
KeyStoreCertPathValidatorException.getReason(API level <24)CertificateExceptiontypes to determine a better statusSystem.Net.Security
TrustManager. Android doesn't allow defining a class via JNI, so doing this would involve actually creating/shipping a Java class.KeyStoreand useTrustManagerFactoryto create and initialize a trust manager with it.Clean-up
runtime/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt
Lines 45 to 47 in f64246c
Other