1- using System ;
1+ /* X509.cs
2+ *
3+ * Copyright (C) 2006-2025 wolfSSL Inc.
4+ *
5+ * This file is part of wolfSSL.
6+ *
7+ * wolfSSL is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; either version 2 of the License, or
10+ * (at your option) any later version.
11+ *
12+ * wolfSSL is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+ */
21+
22+ using System ;
223using System . Runtime . InteropServices ;
324using System . Text ;
425using System . Threading ;
@@ -9,6 +30,23 @@ public class X509
930 {
1031 private const string wolfssl_dll = "wolfssl.dll" ;
1132
33+ #if WindowsCE
34+ [ DllImport ( wolfssl_dll ) ]
35+ private extern static int wolfSSL_X509_get_pubkey_buffer ( IntPtr x509 , IntPtr buf , IntPtr bufSz ) ;
36+ [ DllImport ( wolfssl_dll ) ]
37+ private extern static IntPtr wolfSSL_X509_get_der ( IntPtr x509 , IntPtr bufSz ) ;
38+ [ DllImport ( wolfssl_dll ) ]
39+ private extern static void wolfSSL_X509_free ( IntPtr x509 ) ;
40+ [ DllImport ( wolfssl_dll ) ]
41+ private extern static int wc_DerToPem ( IntPtr der , int derSz , IntPtr pem , int pemSz , int type ) ;
42+
43+ [ DllImport ( wolfssl_dll ) ]
44+ private extern static IntPtr wolfSSL_X509_get_name_oneline ( IntPtr x509Name , IntPtr buf , int bufSz ) ;
45+ [ DllImport ( wolfssl_dll ) ]
46+ private extern static IntPtr wolfSSL_X509_get_subject_name ( IntPtr x509 ) ;
47+ [ DllImport ( wolfssl_dll ) ]
48+ private extern static IntPtr wolfSSL_X509_get_issuer_name ( IntPtr x509 ) ;
49+ #else
1250 [ DllImport ( wolfssl_dll , CallingConvention = CallingConvention . Cdecl ) ]
1351 private extern static int wolfSSL_X509_get_pubkey_buffer ( IntPtr x509 , IntPtr buf , IntPtr bufSz ) ;
1452 [ DllImport ( wolfssl_dll , CallingConvention = CallingConvention . Cdecl ) ]
@@ -25,6 +63,7 @@ public class X509
2563 private extern static IntPtr wolfSSL_X509_get_subject_name ( IntPtr x509 ) ;
2664 [ DllImport ( wolfssl_dll , CallingConvention = CallingConvention . Cdecl ) ]
2765 private extern static IntPtr wolfSSL_X509_get_issuer_name ( IntPtr x509 ) ;
66+ #endif
2867
2968 private IntPtr x509 ;
3069 private int type ;
@@ -51,11 +90,12 @@ public X509(IntPtr x509, bool isDynamic)
5190 this . x509 = x509 ;
5291 ret = wolfSSL_X509_get_name_oneline (
5392 wolfSSL_X509_get_issuer_name ( this . x509 ) , IntPtr . Zero , 0 ) ;
54- this . Issuer = Marshal . PtrToStringAnsi ( ret ) ;
93+ this . Issuer = wolfssl . PtrToStringAnsi ( ret ) ;
5594
5695 ret = wolfSSL_X509_get_name_oneline (
5796 wolfSSL_X509_get_subject_name ( this . x509 ) , IntPtr . Zero , 0 ) ;
58- this . Subject = Marshal . PtrToStringAnsi ( ret ) ;
97+ this . Subject = wolfssl . PtrToStringAnsi ( ret ) ;
98+
5999 this . isDynamic = isDynamic ;
60100 }
61101
0 commit comments