?? storesh.cs
字號:
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-issuer <name> Match issuer name.");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-eku <EKU> Must have specified EKU.");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-sha1 <sha1> Match thumbprint.");
Console.WriteLine();
Console.Write("[v]iew <idx>".PadRight(HELP_PAD, ' '));
Console.WriteLine("<idx> is the number of the certificate to view");
Console.WriteLine();
Console.Write("rem <idx>".PadRight(HELP_PAD, ' '));
Console.WriteLine("<idx> is the number of the certificate to remove");
Console.WriteLine();
Console.Write("displa[y] <idx>".PadRight(HELP_PAD, ' '));
Console.WriteLine("<idx> is the number of the certificate to display");
Console.WriteLine();
Console.Write("[c]reate <store>".PadRight(HELP_PAD, ' '));
Console.WriteLine("<store> is the name of the store to create");
Console.WriteLine();
Console.Write("del <store>".PadRight(HELP_PAD, ' '));
Console.WriteLine("<store> is the name of the store to delete");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "This cannot be a system store");
Console.WriteLine();
Console.Write("[e]xport <idx> <file>".PadRight(HELP_PAD, ' '));
Console.WriteLine("<idx> is the number of the certificate to display");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<file> is the destination filename");
Console.WriteLine();
Console.Write("[p]fxexport <idx> <file> <pw>".PadRight(HELP_PAD, ' '));
Console.WriteLine("<idx> is the number of the certificate to display");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<file> is the destination filename");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<pw> is the password");
Console.WriteLine();
Console.Write("[i]mport <file> <pw> [-key e|p]".PadRight(HELP_PAD, ' '));
Console.WriteLine("<file> is the input filename");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "<pw> is the filename password");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-key: e is exportable");
Console.WriteLine("".PadRight(HELP_PAD, ' ')+ "-key: p is user protected. Both may be specified");
}
public static String ToColumn (String s, int i)
{
String retval;
if (s == null || i > s.Length )
{
retval = s.PadRight(i);
}
else
{
retval = s.Substring(0,i).PadRight(i,' ');
}
return retval;
}
public static void DisplayEKU (EKUs EKUs)
{
if (EKUs.Count > 0)
{
OID OID;
OID = new OIDClass();
foreach (EKU EKU in EKUs)
{
OID.Value = EKU.OID;
Console.WriteLine( " " + OID.FriendlyName + " (" + OID.Value + ")" );
}
OID = null;
}
}
public static void DisplayCertificate ( Certificate Certificate , String Title)
{
String[] KeySpecStrings = {"Unknown", "Exchange","Signature" };
String[] ProviderTypes = { "Unknown",
"PROV_RSA_FULL",
"PROV_RSA_SIG",
"PROV_DSS",
"PROV_FORTEZZA",
"PROV_MS_EXCHANGE",
"PROV_SSL",
"PROV_STT_MER",
"PROV_STT_ACQ",
"PROV_STT_BRND",
"PROV_STT_ROOT",
"PROV_STT_ISS",
"PROV_RSA_SCHANNEL",
"PROV_DSS_DH",
"PROV_EC_ECDSA_SIG",
"PROV_EC_ECNRA_SIG",
"PROV_EC_ECDSA_FULL",
"PROV_EC_ECNRA_FULL",
"PROV_DH_SCHANNEL",
"PROV_SPYRUS_LYNKS",
"PROV_RNG",
"PROV_INTEL_SEC",
"PROV_REPLACE_OWF",
"PROV_RSA_AES" };
//int iIndex = 0;
Console.WriteLine( Title );
Console.WriteLine();
Console.WriteLine( "Subject Name:");
Console.WriteLine( " Simple name = " + Certificate.SubjectName);
Console.WriteLine( " Email name = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME));
Console.WriteLine( " UPN name = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_UPN));
Console.WriteLine( " DNS name = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_DNS_NAME));
Console.WriteLine();
Console.WriteLine( "Issuer Name: " + Certificate.IssuerName);
Console.WriteLine();
Console.WriteLine( "Serial Number: " + Certificate.SerialNumber);
Console.WriteLine();
Console.WriteLine( "Not Before: " + Certificate.ValidFromDate);
Console.WriteLine();
Console.WriteLine( "Not After: " + Certificate.ValidToDate);
Console.WriteLine();
Console.WriteLine( "SHA1 Hash: " + Certificate.Thumbprint);
Console.WriteLine();
Console.WriteLine( "IsValid: " + Certificate.IsValid().Result);
Console.WriteLine();
Console.WriteLine( "Archived: " + Certificate.Archived);
Console.WriteLine();
if (Certificate.BasicConstraints().IsPresent)
{
Console.WriteLine( "Basic Constraints:" );
Console.WriteLine( " Critical = " + Certificate.BasicConstraints().IsCritical );
Console.WriteLine( " CA = " + Certificate.BasicConstraints().IsCertificateAuthority );
Console.WriteLine( " PathLenConstraint = ");
if (Certificate.BasicConstraints().IsPathLenConstraintPresent)
{
Console.WriteLine( Certificate.BasicConstraints().PathLenConstraint);
}
else
{
Console.WriteLine( "Not present.");
}
}
else
{
Console.WriteLine( "Basic Constraints: Not present." );
}
Console.WriteLine();
if (Certificate.KeyUsage().IsPresent)
{
Console.WriteLine( "Key Usage:");
Console.WriteLine( " Critical = " + Certificate.KeyUsage().IsCritical);
Console.WriteLine( " IsDigitalSignatureEnabled = " + Certificate.KeyUsage().IsDigitalSignatureEnabled );
Console.WriteLine( " IsNonRepudiationEnabled = " + Certificate.KeyUsage().IsNonRepudiationEnabled);
Console.WriteLine( " IsKeyEnciphermentEnabled = " + Certificate.KeyUsage().IsKeyEnciphermentEnabled);
Console.WriteLine( " IsDataEnciphermentEnabled = " + Certificate.KeyUsage().IsDataEnciphermentEnabled);
Console.WriteLine( " IsKeyAgreementEnabled = " + Certificate.KeyUsage().IsKeyAgreementEnabled);
Console.WriteLine( " IsKeyCertSignEnabled = " + Certificate.KeyUsage().IsKeyCertSignEnabled);
Console.WriteLine( " IsCRLSignEnabled = " + Certificate.KeyUsage().IsCRLSignEnabled);
Console.WriteLine( " IsEncipherOnlyEnabled = " + Certificate.KeyUsage().IsEncipherOnlyEnabled);
Console.WriteLine( " IsDecipherOnlyEnabled = " + Certificate.KeyUsage().IsDecipherOnlyEnabled);
}
else
{
Console.WriteLine( "Key Usage: Not present.");
}
Console.WriteLine();
if (Certificate.ExtendedKeyUsage().IsPresent)
{
if (Certificate.ExtendedKeyUsage().EKUs.Count > 0)
{
OID OID;
OID = new OIDClass();
Console.WriteLine( "Extended Key Usage:");
Console.WriteLine( " Critical = " + Certificate.ExtendedKeyUsage().IsCritical);
foreach (EKU EKU in Certificate.ExtendedKeyUsage().EKUs)
{
OID.Value = EKU.OID;
Console.WriteLine( " " + OID.FriendlyName + " (" + OID.Value + ")" );
}
OID = null;
}
else
{
Console.WriteLine( "Extended Key Usage: Not valid for any usage.");
Console.WriteLine( " Critical = " + Certificate.ExtendedKeyUsage().IsCritical );
}
}
else
{
Console.WriteLine( "Extended Key Usage: Not present (valid for all usages).");
}
Console.WriteLine();
if (Certificate.Template().IsPresent)
{
Console.WriteLine( "Template:");
Console.WriteLine( " Critical = " + Certificate.Template().IsCritical);
Console.WriteLine( " Name = " + Certificate.Template().Name);
Console.WriteLine( " OID = " + Certificate.Template().OID.FriendlyName + "(" + Certificate.Template().OID.Value + ")");
Console.WriteLine( " Major = " + Certificate.Template().MajorVersion);
Console.WriteLine( " Minor = " + Certificate.Template().MinorVersion);
}
else
{
Console.WriteLine( "Template: Not present.");
}
Console.WriteLine();
Console.WriteLine( "Public Key:");
Console.WriteLine( " Algorithm = " + Certificate.PublicKey().Algorithm.FriendlyName + "(" + Certificate.PublicKey().Algorithm.Value + ")");
Console.WriteLine( " Length = " + Certificate.PublicKey().Length + " bits");
Console.WriteLine( " Key blob = " + Certificate.PublicKey().EncodedKey.Format(true));
Console.WriteLine( " Parameters = " + Certificate.PublicKey().EncodedParameters.Format(true));
if (Certificate.HasPrivateKey())
{
Console.WriteLine( "Private Key:");
Console.WriteLine( " Container name = " + Certificate.PrivateKey.ContainerName);
//Don't display unique container name for hardware token because it may cause UI to be displayed.
if (! Certificate.PrivateKey.IsHardwareDevice())
{
Console.WriteLine( " Unique name = " + Certificate.PrivateKey.UniqueContainerName);
}
Console.WriteLine( " Provider name = " + Certificate.PrivateKey.ProviderName);
Console.WriteLine( " Provider type = " );
if (Convert.ToInt32(Certificate.PrivateKey.ProviderType) > ProviderTypes.GetUpperBound(0))
{
Console.WriteLine( ProviderTypes[0] + " (" + Convert.ToString(Certificate.PrivateKey.ProviderType) + ")");
}
else
{
Console.WriteLine( ProviderTypes[Convert.ToInt32(Certificate.PrivateKey.ProviderType)] + " (" + Convert.ToString(Certificate.PrivateKey.ProviderType) + ")");
}
Console.WriteLine( " Key spec = " );
if (Convert.ToInt32(Certificate.PrivateKey.KeySpec) > KeySpecStrings.GetUpperBound(0))
{
Console.WriteLine( KeySpecStrings[0] + " (" + Convert.ToString(Certificate.PrivateKey.KeySpec) + ")");
}
else
{
Console.WriteLine( KeySpecStrings[Convert.ToInt32(Certificate.PrivateKey.KeySpec)] + " (" + Convert.ToString(Certificate.PrivateKey.KeySpec) + ")");
}
Console.WriteLine( " Accessible = " + Certificate.PrivateKey.IsAccessible());
Console.WriteLine( " Protected = " + Certificate.PrivateKey.IsProtected());
Console.WriteLine( " Exportable = " + Certificate.PrivateKey.IsExportable());
Console.WriteLine( " Removable = " + Certificate.PrivateKey.IsRemovable());
Console.WriteLine( " Machine keyset = " + Certificate.PrivateKey.IsMachineKeyset());
Console.WriteLine( " Hardware storage = " + Certificate.PrivateKey.IsHardwareDevice());
}
else
{
Console.WriteLine( "Private Key: Not found." );
}
Console.WriteLine();
if (true)
{
int iIndex = 0;
foreach (Extension Extension in Certificate.Extensions())
{
iIndex++;
Console.WriteLine( "Extension #" + Convert.ToString(iIndex) + ": " + Extension.OID.FriendlyName + "(" + Extension.OID.Value + ")");
Console.WriteLine( " " + Extension.EncodedData.Format(true));
if (Extension.EncodedData.Decoder() != null)
{
switch (Extension.OID.Value)
{
case Constants.CAPICOM_CERT_POLICIES_OID:
{
CertificatePolicies CertPolicies;
int pIndex = 0;
CertPolicies = (CertificatePolicies)Extension.EncodedData.Decoder();
Console.WriteLine( "Decoded Certificate Policies: " + Convert.ToString(CertPolicies.Count) + " PolicyInformation(s)");
foreach (PolicyInformation PolicyInformation in CertPolicies)
{
int qIndex = 0;
pIndex++;
Console.WriteLine( " PolicyInformation #" + Convert.ToString(pIndex) + ": " + Convert.ToString(PolicyInformation.Qualifiers.Count) + " Qualifier(s)");
Console.WriteLine( " OID = " + PolicyInformation.OID.FriendlyName + "(" + PolicyInformation.OID.Value + ")");
foreach (Qualifier Qualifier in PolicyInformation.Qualifiers)
{
qIndex++;
Console.WriteLine( " Qualifier #" + Convert.ToString(qIndex) + ":");
Console.WriteLine( " OID = " + Qualifier.OID.FriendlyName + "(" + Qualifier.OID.Value + ")");
Console.WriteLine( " CPS URI = " + Qualifier.CPSPointer);
Console.WriteLine( " Organization name = " + Qualifier.OrganizationName);
Console.WriteLine( " Notice number(s) = ");
if (Qualifier.NoticeNumbers != null)
{
foreach (NoticeNumbers NoticeNumber in Qualifier.NoticeNumbers)
{
Console.WriteLine( Convert.ToString(NoticeNumber));
}
}
Console.WriteLine();
Console.WriteLine( " Explicit text = " + Qualifier.ExplicitText);
}
Console.WriteLine();
}
break;
}
}
}
}
if (iIndex == 0)
{
Console.WriteLine( "Extension: None.");
Console.WriteLine();
}
iIndex = 0;
foreach (ExtendedProperty ExtendedProperty in Certificate.ExtendedProperties())
{
iIndex ++;
Console.WriteLine( "Property #" + Convert.ToString(iIndex) + " (ID = " + ExtendedProperty.PropID + "):" );
Console.WriteLine( " " + ExtendedProperty.get_Value(CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64));
}
if (iIndex == 0)
{
Console.WriteLine( "Property: None.");
Console.WriteLine();
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -