Closed
Description
Description
The following PowerShell code demonstrates the error:
PS C:\> [System.Security.Cryptography.CryptoConfig]::EncodeOID('1.3.6.1.4.1.311.21.8.2473183039')
MethodInvocationException: Exception calling "EncodeOID" with "1" argument(s): "Value was either too large or too small for an Int32."
PS C:\> $error[0].exception.innerexception
TargetSite : Void ThrowOverflowOrFormatException(ParsingStatus, System.TypeCode)
StackTrace : at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)
at System.Int32.Parse(String s, IFormatProvider provider)
at System.Security.Cryptography.CryptoConfig.EncodeOID(String str)
The affected code is here:
The error occurs because the value 2473183039
does not fit in an int
type, therefore the code throws an exception. However, that value is valid for an OID.
Configuration
All versions of .NET appear to be affected.
Regression?
No
Other information
Originally ran into it here: Crypt32/pkix.net#44