@@ -91,7 +91,16 @@ public X509Certificate(byte[] certificate, string password)
9191 /// </remarks>
9292 public X509Certificate ( string certificate )
9393 {
94- _certificate = Encoding . UTF8 . GetBytes ( certificate ) ;
94+ var tempCertificate = Encoding . UTF8 . GetBytes ( certificate ) ;
95+
96+ //////////////////////////////////////////////
97+ // because this is parsing from a string //
98+ // we need to keep the terminator //
99+ //////////////////////////////////////////////
100+ _certificate = new byte [ tempCertificate . Length + 1 ] ;
101+ Array . Copy ( tempCertificate , _certificate , tempCertificate . Length ) ;
102+ _certificate [ _certificate . Length - 1 ] = 0 ;
103+
95104 _password = "" ;
96105
97106 ParseCertificate ( _certificate , _password , ref _issuer , ref _subject , ref _effectiveDate , ref _expirationDate ) ;
@@ -108,10 +117,19 @@ public X509Certificate(string certificate)
108117 /// </remarks>
109118 public X509Certificate ( string certificate , string password )
110119 {
111- _certificate = Encoding . UTF8 . GetBytes ( certificate ) ;
112120 _password = password ;
113121
114- ParseCertificate ( Encoding . UTF8 . GetBytes ( certificate ) , _password , ref _issuer , ref _subject , ref _effectiveDate , ref _expirationDate ) ;
122+ var tempCertificate = Encoding . UTF8 . GetBytes ( certificate ) ;
123+
124+ //////////////////////////////////////////////
125+ // because this is parsing from a string //
126+ // we need to keep the terminator //
127+ //////////////////////////////////////////////
128+ _certificate = new byte [ tempCertificate . Length + 1 ] ;
129+ Array . Copy ( tempCertificate , _certificate , tempCertificate . Length ) ;
130+ _certificate [ _certificate . Length - 1 ] = 0 ;
131+
132+ ParseCertificate ( _certificate , _password , ref _issuer , ref _subject , ref _effectiveDate , ref _expirationDate ) ;
115133 }
116134
117135 /// <summary>
0 commit comments