I'm trying to call CertFindCertificateInStore to find all certificates in the
store that have the Code Signing enhanced key usage. I'm running into
problems marshalling the array of OIDs in _CTL_USAGE. I keep getting a "This
type can not be marshalled as a structure field."
Does anyone have any ideas as to what I'm doing wrong? Here's the code:
namespace CertSignTest
{
using System;
using System.Diagnostics;
using System.Text;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.ComponentModel;
public class WinCapi
{
/*
HCERTSTORE WINAPI CertOpenSystemStore(HCRYPTPROV hprov, LPTCSTR
szSubsystemProtocol);
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags);
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(
HCERTSTORE hCertStore,
DWORD dwCertEncodingType,
DWORD dwFindFlags,
DWORD dwFindType,
const void* pvFindPara,
PCCERT_CONTEXT pPrevCertContext);
BOOL WINAPI CertFreeCertificateContext(
PCCERT_CONTEXT pCertContext
);
typedef struct _CTL_USAGE {
DWORD cUsageIdentifier;
LPSTR *rgpszUsageIdentifier; // array of pszObjId
} CTL_USAGE, *PCTL_USAGE, CERT_ENHKEY_USAGE, *PCERT_ENHKEY_USAGE;
*/
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct CRYPT_OID_INFO
{
public uint cbSize;
[MarshalAs(UnmanagedType.LPStr)] public String pszOID;
[MarshalAs(UnmanagedType.LPWStr)]public String pwszName;
public uint dwGroupID;
public uint dwValue;
public int cbData; //ExtraInfo blob
public IntPtr pbData;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct _CTL_USAGE
{
public int cUsageIdentifier;
[MarshalAs(UnmanagedType.ByValArray)]
public string[] rgpszUseageIdentifier;
}
[DllImport("crypt32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern IntPtr CertOpenSystemStore(
IntPtr hCryptProv,
string storename) ;
[DllImport("crypt32.dll", SetLastError=true)]
public static extern bool CertCloseStore(
IntPtr hCertStore,
uint dwFlags) ;
[DllImport("crypt32.dll", SetLastError=true)]
public static extern IntPtr CertFindCertificateInStore(
IntPtr hCertStore,
uint dwCertEncodingType,
uint dwFindFlags,
uint dwFindType,
ref WinCapi._CTL_USAGE pvFindPara,
IntPtr pPrevCertCntxt) ;
[DllImport("crypt32.dll", SetLastError=true)]
public static extern bool CertFreeCertificateContext(
IntPtr hCertStore) ;
}
public class SimpleCert
{
const string szOID_PKIX_KP_CODE_SIGNING = "1.3.6.1.5.5.7.3.3";
const string MY = "MY";
const string OTHERS = "AddressBook";
const uint PKCS_7_ASN_ENCODING = 0x00010000;
const uint X509_ASN_ENCODING = 0x00000001;
const uint CERT_FIND_SUBJECT_STR = 0x00080007;
const uint CERT_FIND_ENHKEY_USAGE = 0x000A0000;
static uint MY_ENCODING_TYPE = PKCS_7_ASN_ENCODING | X509_ASN_ENCODING ;
public static void Main()
{
IntPtr hSysStore = IntPtr.Zero;
IntPtr hCertCntxt = IntPtr.Zero;
IntPtr hStructure = IntPtr.Zero;
WinCapi._CTL_USAGE test = new WinCapi._CTL_USAGE();
string[] strTest = new string[1];
strTest[0] = szOID_PKIX_KP_CODE_SIGNING;
hSysStore = WinCapi.CertOpenSystemStore(IntPtr.Zero, MY) ;
Console.WriteLine("Store Handle:\t0x{0:X}", hSysStore.ToInt32());
test.cUsageIdentifier = 1;
test.rgpszUseageIdentifier = new string[1];
test.rgpszUseageIdentifier[0] = szOID_PKIX_KP_CODE_SIGNING;
if(hSysStore != IntPtr.Zero)
{
hCertCntxt=WinCapi.CertFindCertificateInStore(
hSysStore,
MY_ENCODING_TYPE,
0,
CERT_FIND_ENHKEY_USAGE,
ref test,
IntPtr.Zero) ;
Debug.WriteLine(Marshal.GetLastWin32Error().ToStri ng());
while(hCertCntxt != IntPtr.Zero)
{
Console.WriteLine("CertContext:\t0x{0:X}", hCertCntxt.ToInt32()) ;
X509Certificate foundcert = new X509Certificate(hCertCntxt);
Console.WriteLine("\nFound certificate with SubjectName string
\"{0}\"",lpszCertSubject);
Console.WriteLine("SubjectName:\t{0}", foundcert.GetName());
Console.WriteLine("Serial No:\t{0}", foundcert.GetSerialNumberString());
Console.WriteLine("HashString:\t{0}" , foundcert.GetCertHashString());
Console.WriteLine("PublicKey:\t{0}",foundcert.GetP ublicKey().ToString());
Console.WriteLine("Issuer:\t {0}",foundcert.GetIssuerName());
hCertCntxt=WinCapi.CertFindCertificateInStore(
hSysStore,
MY_ENCODING_TYPE,
0,
CERT_FIND_ENHKEY_USAGE,
ref test,
hCertCntxt) ;
}
}
//------- Clean Up -----------
if(hCertCntxt != IntPtr.Zero)
WinCapi.CertFreeCertificateContext(hCertCntxt);
if(hSysStore != IntPtr.Zero)
WinCapi.CertCloseStore(hSysStore, 0) ;
}
} 3 5457
Have you been to pinvoke.net they have an example for exactly what you are
trying to do: http://pinvoke.net/default.aspx/cryp...ificateInStore
In fact it is the best place for an interop related API issues IMHO.
HTH
Ollie Riches
"Charles Denny" <Ch**********@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com... I'm trying to call CertFindCertificateInStore to find all certificates in the store that have the Code Signing enhanced key usage. I'm running into problems marshalling the array of OIDs in _CTL_USAGE. I keep getting a "This type can not be marshalled as a structure field."
Does anyone have any ideas as to what I'm doing wrong? Here's the code:
namespace CertSignTest { using System; using System.Diagnostics; using System.Text; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; using System.ComponentModel;
public class WinCapi {
/* HCERTSTORE WINAPI CertOpenSystemStore(HCRYPTPROV hprov, LPTCSTR szSubsystemProtocol); BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags);
PCCERT_CONTEXT WINAPI CertFindCertificateInStore( HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, const void* pvFindPara, PCCERT_CONTEXT pPrevCertContext);
BOOL WINAPI CertFreeCertificateContext( PCCERT_CONTEXT pCertContext );
typedef struct _CTL_USAGE { DWORD cUsageIdentifier; LPSTR *rgpszUsageIdentifier; // array of pszObjId } CTL_USAGE, *PCTL_USAGE, CERT_ENHKEY_USAGE, *PCERT_ENHKEY_USAGE;
*/
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct CRYPT_OID_INFO { public uint cbSize; [MarshalAs(UnmanagedType.LPStr)] public String pszOID; [MarshalAs(UnmanagedType.LPWStr)]public String pwszName; public uint dwGroupID; public uint dwValue; public int cbData; //ExtraInfo blob public IntPtr pbData; }
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct _CTL_USAGE { public int cUsageIdentifier; [MarshalAs(UnmanagedType.ByValArray)] public string[] rgpszUseageIdentifier; }
[DllImport("crypt32.dll", CharSet=CharSet.Auto, SetLastError=true)] public static extern IntPtr CertOpenSystemStore( IntPtr hCryptProv, string storename) ;
[DllImport("crypt32.dll", SetLastError=true)] public static extern bool CertCloseStore( IntPtr hCertStore, uint dwFlags) ;
[DllImport("crypt32.dll", SetLastError=true)] public static extern IntPtr CertFindCertificateInStore( IntPtr hCertStore, uint dwCertEncodingType, uint dwFindFlags, uint dwFindType, ref WinCapi._CTL_USAGE pvFindPara, IntPtr pPrevCertCntxt) ;
[DllImport("crypt32.dll", SetLastError=true)] public static extern bool CertFreeCertificateContext( IntPtr hCertStore) ;
}
public class SimpleCert { const string szOID_PKIX_KP_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; const string MY = "MY"; const string OTHERS = "AddressBook"; const uint PKCS_7_ASN_ENCODING = 0x00010000; const uint X509_ASN_ENCODING = 0x00000001; const uint CERT_FIND_SUBJECT_STR = 0x00080007; const uint CERT_FIND_ENHKEY_USAGE = 0x000A0000;
static uint MY_ENCODING_TYPE = PKCS_7_ASN_ENCODING | X509_ASN_ENCODING ;
public static void Main() { IntPtr hSysStore = IntPtr.Zero; IntPtr hCertCntxt = IntPtr.Zero; IntPtr hStructure = IntPtr.Zero;
WinCapi._CTL_USAGE test = new WinCapi._CTL_USAGE();
string[] strTest = new string[1]; strTest[0] = szOID_PKIX_KP_CODE_SIGNING;
hSysStore = WinCapi.CertOpenSystemStore(IntPtr.Zero, MY) ; Console.WriteLine("Store Handle:\t0x{0:X}", hSysStore.ToInt32());
test.cUsageIdentifier = 1; test.rgpszUseageIdentifier = new string[1]; test.rgpszUseageIdentifier[0] = szOID_PKIX_KP_CODE_SIGNING; if(hSysStore != IntPtr.Zero) { hCertCntxt=WinCapi.CertFindCertificateInStore( hSysStore, MY_ENCODING_TYPE, 0, CERT_FIND_ENHKEY_USAGE, ref test, IntPtr.Zero) ;
Debug.WriteLine(Marshal.GetLastWin32Error().ToStri ng());
while(hCertCntxt != IntPtr.Zero) { Console.WriteLine("CertContext:\t0x{0:X}", hCertCntxt.ToInt32()) ; X509Certificate foundcert = new X509Certificate(hCertCntxt); Console.WriteLine("\nFound certificate with SubjectName string \"{0}\"",lpszCertSubject); Console.WriteLine("SubjectName:\t{0}", foundcert.GetName()); Console.WriteLine("Serial No:\t{0}", foundcert.GetSerialNumberString()); Console.WriteLine("HashString:\t{0}" , foundcert.GetCertHashString()); Console.WriteLine("PublicKey:\t{0}",foundcert.GetP ublicKey().ToString()); Console.WriteLine("Issuer:\t {0}",foundcert.GetIssuerName());
hCertCntxt=WinCapi.CertFindCertificateInStore( hSysStore, MY_ENCODING_TYPE, 0, CERT_FIND_ENHKEY_USAGE, ref test, hCertCntxt) ; } }
//------- Clean Up ----------- if(hCertCntxt != IntPtr.Zero) WinCapi.CertFreeCertificateContext(hCertCntxt); if(hSysStore != IntPtr.Zero) WinCapi.CertCloseStore(hSysStore, 0) ; }
}
Thanks Ollie, however that doesn't really help me as I'm having to pass the
CTL_USAGE structure to pzFindPara of the CertFindCertificateInStore. This
structure has an array of strings. I need to be able to successfully marshal
the CTL_USAGE structure so that I can search for Enhanced Key Usage OIDs
rather than the subject name that is given in the example.
The problem with the website you just gave me is that pszFindPara can be one
of a number of types, and they only have an example for one of those types.
:) I suppose if I could work out how to get a IntPtr assigned to the
structure, I could try just passing that.
Regards,
Charles
"Ollie Riches" wrote: Have you been to pinvoke.net they have an example for exactly what you are trying to do:
http://pinvoke.net/default.aspx/cryp...ificateInStore
In fact it is the best place for an interop related API issues IMHO.
HTH
Ollie Riches
"Charles Denny" <Ch**********@discussions.microsoft.com> wrote in message news:6C**********************************@microsof t.com... I'm trying to call CertFindCertificateInStore to find all certificates in the store that have the Code Signing enhanced key usage. I'm running into problems marshalling the array of OIDs in _CTL_USAGE. I keep getting a "This type can not be marshalled as a structure field."
Does anyone have any ideas as to what I'm doing wrong? Here's the code:
namespace CertSignTest { using System; using System.Diagnostics; using System.Text; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; using System.ComponentModel;
public class WinCapi {
/* HCERTSTORE WINAPI CertOpenSystemStore(HCRYPTPROV hprov, LPTCSTR szSubsystemProtocol); BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags);
PCCERT_CONTEXT WINAPI CertFindCertificateInStore( HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, const void* pvFindPara, PCCERT_CONTEXT pPrevCertContext);
BOOL WINAPI CertFreeCertificateContext( PCCERT_CONTEXT pCertContext );
typedef struct _CTL_USAGE { DWORD cUsageIdentifier; LPSTR *rgpszUsageIdentifier; // array of pszObjId } CTL_USAGE, *PCTL_USAGE, CERT_ENHKEY_USAGE, *PCERT_ENHKEY_USAGE;
*/
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct CRYPT_OID_INFO { public uint cbSize; [MarshalAs(UnmanagedType.LPStr)] public String pszOID; [MarshalAs(UnmanagedType.LPWStr)]public String pwszName; public uint dwGroupID; public uint dwValue; public int cbData; //ExtraInfo blob public IntPtr pbData; }
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct _CTL_USAGE { public int cUsageIdentifier; [MarshalAs(UnmanagedType.ByValArray)] public string[] rgpszUseageIdentifier; }
[DllImport("crypt32.dll", CharSet=CharSet.Auto, SetLastError=true)] public static extern IntPtr CertOpenSystemStore( IntPtr hCryptProv, string storename) ;
[DllImport("crypt32.dll", SetLastError=true)] public static extern bool CertCloseStore( IntPtr hCertStore, uint dwFlags) ;
[DllImport("crypt32.dll", SetLastError=true)] public static extern IntPtr CertFindCertificateInStore( IntPtr hCertStore, uint dwCertEncodingType, uint dwFindFlags, uint dwFindType, ref WinCapi._CTL_USAGE pvFindPara, IntPtr pPrevCertCntxt) ;
[DllImport("crypt32.dll", SetLastError=true)] public static extern bool CertFreeCertificateContext( IntPtr hCertStore) ;
}
public class SimpleCert { const string szOID_PKIX_KP_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; const string MY = "MY"; const string OTHERS = "AddressBook"; const uint PKCS_7_ASN_ENCODING = 0x00010000; const uint X509_ASN_ENCODING = 0x00000001; const uint CERT_FIND_SUBJECT_STR = 0x00080007; const uint CERT_FIND_ENHKEY_USAGE = 0x000A0000;
static uint MY_ENCODING_TYPE = PKCS_7_ASN_ENCODING | X509_ASN_ENCODING ;
public static void Main() { IntPtr hSysStore = IntPtr.Zero; IntPtr hCertCntxt = IntPtr.Zero; IntPtr hStructure = IntPtr.Zero;
WinCapi._CTL_USAGE test = new WinCapi._CTL_USAGE();
string[] strTest = new string[1]; strTest[0] = szOID_PKIX_KP_CODE_SIGNING;
hSysStore = WinCapi.CertOpenSystemStore(IntPtr.Zero, MY) ; Console.WriteLine("Store Handle:\t0x{0:X}", hSysStore.ToInt32());
test.cUsageIdentifier = 1; test.rgpszUseageIdentifier = new string[1]; test.rgpszUseageIdentifier[0] = szOID_PKIX_KP_CODE_SIGNING; if(hSysStore != IntPtr.Zero) { hCertCntxt=WinCapi.CertFindCertificateInStore( hSysStore, MY_ENCODING_TYPE, 0, CERT_FIND_ENHKEY_USAGE, ref test, IntPtr.Zero) ;
Debug.WriteLine(Marshal.GetLastWin32Error().ToStri ng());
while(hCertCntxt != IntPtr.Zero) { Console.WriteLine("CertContext:\t0x{0:X}", hCertCntxt.ToInt32()) ; X509Certificate foundcert = new X509Certificate(hCertCntxt); Console.WriteLine("\nFound certificate with SubjectName string \"{0}\"",lpszCertSubject); Console.WriteLine("SubjectName:\t{0}", foundcert.GetName()); Console.WriteLine("Serial No:\t{0}", foundcert.GetSerialNumberString()); Console.WriteLine("HashString:\t{0}" , foundcert.GetCertHashString()); Console.WriteLine("PublicKey:\t{0}",foundcert.GetP ublicKey().ToString()); Console.WriteLine("Issuer:\t {0}",foundcert.GetIssuerName());
hCertCntxt=WinCapi.CertFindCertificateInStore( hSysStore, MY_ENCODING_TYPE, 0, CERT_FIND_ENHKEY_USAGE, ref test, hCertCntxt) ; } }
//------- Clean Up ----------- if(hCertCntxt != IntPtr.Zero) WinCapi.CertFreeCertificateContext(hCertCntxt); if(hSysStore != IntPtr.Zero) WinCapi.CertCloseStore(hSysStore, 0) ; }
}
Charles,
Have you read this page on MSDN: http://msdn.microsoft.com/library/de...gForArrays.asp
HTH
Ollie Riches
"Charles Denny" <Ch**********@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com... Thanks Ollie, however that doesn't really help me as I'm having to pass the CTL_USAGE structure to pzFindPara of the CertFindCertificateInStore. This structure has an array of strings. I need to be able to successfully marshal the CTL_USAGE structure so that I can search for Enhanced Key Usage OIDs rather than the subject name that is given in the example.
The problem with the website you just gave me is that pszFindPara can be one of a number of types, and they only have an example for one of those types. :) I suppose if I could work out how to get a IntPtr assigned to the structure, I could try just passing that.
Regards, Charles
"Ollie Riches" wrote:
Have you been to pinvoke.net they have an example for exactly what you are trying to do:
http://pinvoke.net/default.aspx/cryp...ificateInStore
In fact it is the best place for an interop related API issues IMHO.
HTH
Ollie Riches
"Charles Denny" <Ch**********@discussions.microsoft.com> wrote in message news:6C**********************************@microsof t.com... > I'm trying to call CertFindCertificateInStore to find all certificates > in > the > store that have the Code Signing enhanced key usage. I'm running into > problems marshalling the array of OIDs in _CTL_USAGE. I keep getting a > "This > type can not be marshalled as a structure field." > > Does anyone have any ideas as to what I'm doing wrong? Here's the > code: > > namespace CertSignTest > { > using System; > using System.Diagnostics; > using System.Text; > using System.Runtime.InteropServices; > using System.Security.Cryptography.X509Certificates; > using System.ComponentModel; > > public class WinCapi > { > > /* > HCERTSTORE WINAPI CertOpenSystemStore(HCRYPTPROV hprov, LPTCSTR > szSubsystemProtocol); > BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags); > > PCCERT_CONTEXT WINAPI CertFindCertificateInStore( > HCERTSTORE hCertStore, > DWORD dwCertEncodingType, > DWORD dwFindFlags, > DWORD dwFindType, > const void* pvFindPara, > PCCERT_CONTEXT pPrevCertContext); > > BOOL WINAPI CertFreeCertificateContext( > PCCERT_CONTEXT pCertContext > ); > > typedef struct _CTL_USAGE { > DWORD cUsageIdentifier; > LPSTR *rgpszUsageIdentifier; // array of > pszObjId > } CTL_USAGE, *PCTL_USAGE, CERT_ENHKEY_USAGE, *PCERT_ENHKEY_USAGE; > > */ > > > [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] > public struct CRYPT_OID_INFO > { > public uint cbSize; > [MarshalAs(UnmanagedType.LPStr)] public String pszOID; > [MarshalAs(UnmanagedType.LPWStr)]public String pwszName; > public uint dwGroupID; > public uint dwValue; > public int cbData; //ExtraInfo blob > public IntPtr pbData; > } > > [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] > public struct _CTL_USAGE > { > public int cUsageIdentifier; > [MarshalAs(UnmanagedType.ByValArray)] > public string[] rgpszUseageIdentifier; > } > > [DllImport("crypt32.dll", CharSet=CharSet.Auto, SetLastError=true)] > public static extern IntPtr CertOpenSystemStore( > IntPtr hCryptProv, > string storename) ; > > [DllImport("crypt32.dll", SetLastError=true)] > public static extern bool CertCloseStore( > IntPtr hCertStore, > uint dwFlags) ; > > [DllImport("crypt32.dll", SetLastError=true)] > public static extern IntPtr CertFindCertificateInStore( > IntPtr hCertStore, > uint dwCertEncodingType, > uint dwFindFlags, > uint dwFindType, > ref WinCapi._CTL_USAGE pvFindPara, > IntPtr pPrevCertCntxt) ; > > > [DllImport("crypt32.dll", SetLastError=true)] > public static extern bool CertFreeCertificateContext( > IntPtr hCertStore) ; > > } > > public class SimpleCert > { > const string szOID_PKIX_KP_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; > const string MY = "MY"; > const string OTHERS = "AddressBook"; > const uint PKCS_7_ASN_ENCODING = 0x00010000; > const uint X509_ASN_ENCODING = 0x00000001; > const uint CERT_FIND_SUBJECT_STR = 0x00080007; > const uint CERT_FIND_ENHKEY_USAGE = 0x000A0000; > > static uint MY_ENCODING_TYPE = PKCS_7_ASN_ENCODING | > X509_ASN_ENCODING > ; > > public static void Main() > { > IntPtr hSysStore = IntPtr.Zero; > IntPtr hCertCntxt = IntPtr.Zero; > IntPtr hStructure = IntPtr.Zero; > > WinCapi._CTL_USAGE test = new WinCapi._CTL_USAGE(); > > string[] strTest = new string[1]; > strTest[0] = szOID_PKIX_KP_CODE_SIGNING; > > hSysStore = WinCapi.CertOpenSystemStore(IntPtr.Zero, MY) ; > Console.WriteLine("Store Handle:\t0x{0:X}", hSysStore.ToInt32()); > > test.cUsageIdentifier = 1; > test.rgpszUseageIdentifier = new string[1]; > test.rgpszUseageIdentifier[0] = szOID_PKIX_KP_CODE_SIGNING; > if(hSysStore != IntPtr.Zero) > { > hCertCntxt=WinCapi.CertFindCertificateInStore( > hSysStore, > MY_ENCODING_TYPE, > 0, > CERT_FIND_ENHKEY_USAGE, > ref test, > IntPtr.Zero) ; > > Debug.WriteLine(Marshal.GetLastWin32Error().ToStri ng()); > > while(hCertCntxt != IntPtr.Zero) > { > Console.WriteLine("CertContext:\t0x{0:X}", hCertCntxt.ToInt32()) ; > X509Certificate foundcert = new X509Certificate(hCertCntxt); > Console.WriteLine("\nFound certificate with SubjectName string > \"{0}\"",lpszCertSubject); > Console.WriteLine("SubjectName:\t{0}", foundcert.GetName()); > Console.WriteLine("Serial No:\t{0}", > foundcert.GetSerialNumberString()); > Console.WriteLine("HashString:\t{0}" , foundcert.GetCertHashString()); > Console.WriteLine("PublicKey:\t{0}",foundcert.GetP ublicKey().ToString()); > Console.WriteLine("Issuer:\t {0}",foundcert.GetIssuerName()); > > hCertCntxt=WinCapi.CertFindCertificateInStore( > hSysStore, > MY_ENCODING_TYPE, > 0, > CERT_FIND_ENHKEY_USAGE, > ref test, > hCertCntxt) ; > } > } > > //------- Clean Up ----------- > if(hCertCntxt != IntPtr.Zero) > WinCapi.CertFreeCertificateContext(hCertCntxt); > if(hSysStore != IntPtr.Zero) > WinCapi.CertCloseStore(hSysStore, 0) ; > } > > } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JPRoot |
last post by:
Hi
I wish to set/get a property using System.ComponentModel.ISynchronizeInvoke.Invoke but I cannot find the exact syntax..
Any clue how to do this
(right now I am making GetEnabled/SetEnabled...
|
by: RobbieK |
last post by:
I am hoping someone can help with a strange problem - I am not very
savvy with certificates, so bear with my ignorance in that area. I
have an ASP.NET (1.1) application that calls a web service...
|
by: |
last post by:
Hi all,
HttpWebRequest, and SoapHttpClientProtocol both expose a
ClientCertificates property, which can hold multiple client certificates,
but on the service side, it can only receive one client...
|
by: Rave |
last post by:
This is a long shot, but I thought I'd try it. I am currently using excel as an inventory tool. I currently have a hand-held scanner plugged into a laptop for reading barcodes. Using the "Find and...
|
by: b.fokke |
last post by:
I'd like to connect to a webservice using TLS/SSL. I have two separate
client certificates:
1. A certificate for digital verification
2. A certificate for encryption.
When I use the first one...
|
by: Thomas Due |
last post by:
Hi,
I have a class which monitors a TCP socket. This will on occasion raise an event which can be handled by a GUI.
Now, I am aware of the
if(InvokeRequire) {
EventHandler d = new...
|
by: =?Utf-8?B?Sm9l?= |
last post by:
I know that I have posted this question before, but it is still unresolved
and I don't know where to turn to next.
I have code that is creating a user (works fine), then sets the account
flags...
|
by: iLL |
last post by:
So why is it that we need to use the Invoke method when updating the GUI?
The following is the way we are suppose to update GUI components:
delegate void textIt(object o);
public partial...
|
by: James |
last post by:
Hello everyone,
While loading a page
(http://www.edmonton.ca/portal/server.pt?space=CommunityPage&control=SetCommunity&CommunityID=239)
into a webbrowser control I use invokemember on the...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |