b***@novell.com
2010-10-14 10:45:47 UTC
https://bugzilla.novell.com/show_bug.cgi?id=646491
https://bugzilla.novell.com/show_bug.cgi?id=646491#c0
Summary: Constructor X509Certificate2(byte[]) throws an
exception
Classification: Mono
Product: Mono: Runtime
Version: 2.8.x
Platform: All
OS/Version: All
Status: NEW
Severity: Critical
Priority: P5 - None
Component: interop
AssignedTo: mono-***@lists.ximian.com
ReportedBy: ***@fastwebnet.it
QAContact: mono-***@lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
When I try to load an X509Certificate that is stored as a .p12 file as an
embedded resource assembly, I get its payload as a byte[] and pass it to
X509Certificate2 constructor. Then I get a SecurityException from Mono.Security
Reproducible: Always
Steps to Reproduce:
Try running attached demo project
Actual Results:
Reading file but passing as byte[]
System.Security.Cryptography.CryptographicException: Unable to decode
certificat
e. ---> System.Security.Cryptography.CryptographicException: Input data cannot
b
e coded as a valid certificate. --->
System.Security.Cryptography.CryptographicE
xception: Input data cannot be coded as a valid certificate.
at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x00041] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\Mono.Security.X509
\X509Certificate.cs:113
--- End of inner exception stack trace ---
at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x00352] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\Mono.Security.X509
\X509Certificate.cs:207
at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00043] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\Mono.Security.X509
\X509Certificate.cs:225
at System.Security.Cryptography.X509Certificates.X509Certificate.Import
(Syste
m.Byte[] rawData, System.String password, X509KeyStorageFlags keyStorageFlags)
[
0x0000c] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\System
Security.Cryptography.X509Certificates\X509Certificate20.cs:225
--- End of inner exception stack trace ---
at System.Security.Cryptography.X509Certificates.X509Certificate.Import
(Syste
m.Byte[] rawData, System.String password, X509KeyStorageFlags keyStorageFlags)
[
0x00065] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\System
Security.Cryptography.X509Certificates\X509Certificate20.cs:238
at System.Security.Cryptography.X509Certificates.X509Certificate2.Import
(Syst
em.Byte[] rawData, System.String password, X509KeyStorageFlags keyStorageFlags)
[0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\System\Syste
m.Security.Cryptography.X509Certificates\X509Certificate2.cs:441
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor
(Syste
m.Byte[] rawData) [0x00011] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\
class\System\System.Security.Cryptography.X509Certificates\X509Certificate2.cs:7
2
at Certificate.Program.Main (System.String[] args) [0x00000] in <filename
unkn
own>:0
Expected Results:
I expect the program to output certificate information
Problem occurred in both Mono 2.6.7 and Mono 2.8. Current test done under
Windows but found the same to occur in Linux too.
Workaround: (as soon as you are sure payload is PKCS#12) write the byte[] in a
temporary file and load it with string constructor
https://bugzilla.novell.com/show_bug.cgi?id=646491#c0
Summary: Constructor X509Certificate2(byte[]) throws an
exception
Classification: Mono
Product: Mono: Runtime
Version: 2.8.x
Platform: All
OS/Version: All
Status: NEW
Severity: Critical
Priority: P5 - None
Component: interop
AssignedTo: mono-***@lists.ximian.com
ReportedBy: ***@fastwebnet.it
QAContact: mono-***@lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
When I try to load an X509Certificate that is stored as a .p12 file as an
embedded resource assembly, I get its payload as a byte[] and pass it to
X509Certificate2 constructor. Then I get a SecurityException from Mono.Security
Reproducible: Always
Steps to Reproduce:
Try running attached demo project
Actual Results:
Reading file but passing as byte[]
System.Security.Cryptography.CryptographicException: Unable to decode
certificat
e. ---> System.Security.Cryptography.CryptographicException: Input data cannot
b
e coded as a valid certificate. --->
System.Security.Cryptography.CryptographicE
xception: Input data cannot be coded as a valid certificate.
at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x00041] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\Mono.Security.X509
\X509Certificate.cs:113
--- End of inner exception stack trace ---
at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x00352] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\Mono.Security.X509
\X509Certificate.cs:207
at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00043] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\Mono.Security.X509
\X509Certificate.cs:225
at System.Security.Cryptography.X509Certificates.X509Certificate.Import
(Syste
m.Byte[] rawData, System.String password, X509KeyStorageFlags keyStorageFlags)
[
0x0000c] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\System
Security.Cryptography.X509Certificates\X509Certificate20.cs:225
--- End of inner exception stack trace ---
at System.Security.Cryptography.X509Certificates.X509Certificate.Import
(Syste
m.Byte[] rawData, System.String password, X509KeyStorageFlags keyStorageFlags)
[
0x00065] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\corlib\System
Security.Cryptography.X509Certificates\X509Certificate20.cs:238
at System.Security.Cryptography.X509Certificates.X509Certificate2.Import
(Syst
em.Byte[] rawData, System.String password, X509KeyStorageFlags keyStorageFlags)
[0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\class\System\Syste
m.Security.Cryptography.X509Certificates\X509Certificate2.cs:441
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor
(Syste
m.Byte[] rawData) [0x00011] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.8\mcs\
class\System\System.Security.Cryptography.X509Certificates\X509Certificate2.cs:7
2
at Certificate.Program.Main (System.String[] args) [0x00000] in <filename
unkn
own>:0
Expected Results:
I expect the program to output certificate information
Problem occurred in both Mono 2.6.7 and Mono 2.8. Current test done under
Windows but found the same to occur in Linux too.
Workaround: (as soon as you are sure payload is PKCS#12) write the byte[] in a
temporary file and load it with string constructor
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.