ZebraP12Info Class |
Namespace: Zebra.Sdk.Certificate
The ZebraP12Info type exposes the following members.
Name | Description | |
---|---|---|
ZebraP12Info |
Creates a wrapper that opens up the provided certificate keystore stream.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetAliases |
Get a list of aliases present in the certificate keystore.
| |
GetCaCommonName |
Get the common name of the CA associated with the certificate file.
| |
GetCaCommonName(String) |
Get the common name of the CA associated with the certificate file.
| |
GetCaContent |
Get the content of the ca, which is determined to be all entries in the certificate chain after the first entry.
| |
GetCaContent(String) |
Get the content of the ca, which is determined to be all entries in the certificate chain after the first entry.
| |
GetCaExpirationDate |
Get the expiration data of the CA associated with the certificate file.
| |
GetCaExpirationDate(String) |
Get the expiration data of the CA associated with the certificate file.
| |
GetCertificateCommonName |
Get the common name of the client certificate associated with the certificate file.
| |
GetCertificateCommonName(String) |
Get the common name of the client certificate associated with the certificate file.
| |
GetCertificateContent |
Get the content of the first entry in the certificate's certificate chain.
| |
GetCertificateContent(String) |
Get the content of the first entry in the certificate's certificate chain.
| |
GetCertificateExpirationDate |
Get the expiration data of the client certificate associated with the certificate file.
| |
GetCertificateExpirationDate(String) |
Get the expiration data of the client certificate associated with the certificate file.
| |
GetCertificateIssuer |
Get the issuer of the client certificate.
| |
GetCertificateIssuer(String) |
Get the issuer of the client certificate.
| |
GetEncryptedPrivateKeyContent(String) |
Get the encrypted private key content.
| |
GetEncryptedPrivateKeyContent(String, String) |
Get the encrypted private key content.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetPrivateKeyAlgorithm |
Get the algorithm used by the private key.
| |
GetPrivateKeyAlgorithm(String) |
Get the algorithm used by the private key.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
using System; using System.IO; using System.Text; using Zebra.Sdk.Certificate; using Zebra.Sdk.Comm; using Zebra.Sdk.Printer; public class ZebraP12InfoExample { public static void Main(string[] args) { ZebraP12Info zebraP12Info = null; string p12FilePassword = "P12_PASSWORD"; string p12Alias = "entryAliasToExtract"; string privateKeyEncryptionPassword = "1234"; try { using (FileStream p12InputStream = new FileStream("/path/to/file.p12", FileMode.Open)) { zebraP12Info = new ZebraP12Info(p12InputStream, p12FilePassword); } } catch (FileNotFoundException) { Console.WriteLine("Could not find the p12 file."); } catch (ZebraCertificateException) { Console.WriteLine("Failed to extract contents from the p12 file. Make sure the provided p12 file and password are valid."); } DriverPrinterConnection conn = null; try { string caContent = zebraP12Info.GetCaContent(); string clientCertificateContent = zebraP12Info.GetCertificateContent(); string encryptedPrivateKeyContent = zebraP12Info.GetEncryptedPrivateKeyContent(p12Alias, privateKeyEncryptionPassword); conn = new DriverPrinterConnection("myPrinterDriverName"); conn.Open(); ZebraPrinterLinkOs linkosPrinter = ZebraPrinterFactory.GetLinkOsPrinter(conn); linkosPrinter.StoreFileOnPrinter(Encoding.UTF8.GetBytes(clientCertificateContent), ZebraCertificateInfo.CLIENT_CERT_NRD_PRINTER_FILE_NAME); linkosPrinter.StoreFileOnPrinter(Encoding.UTF8.GetBytes(caContent), ZebraCertificateInfo.CA_CERT_NRD_PRINTER_FILE_NAME); linkosPrinter.StoreFileOnPrinter(Encoding.UTF8.GetBytes(encryptedPrivateKeyContent), ZebraCertificateInfo.CLIENT_PRIVATE_KEY_NRD_PRINTER_FILE_NAME); linkosPrinter.SetSetting("wlan.private_key_password", privateKeyEncryptionPassword); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { if (conn != null) { conn.Close(); } } } }