Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction | Help Version 19.0.2.15
|
Leadtools.MediaStreaming Namespace > NetworkProperties Class : SSLCertificateHash Property |
public object SSLCertificateHash {get; set;}
'Declaration
Public Property SSLCertificateHash As Object
'Usage
Dim instance As NetworkProperties Dim value As Object instance.SSLCertificateHash = value value = instance.SSLCertificateHash
Imports Leadtools Imports Leadtools.MediaStreaming Public _server As Server = Nothing Public _result As Boolean = False Public Sub SetNetworkSSLPropertiesExample() Try ' create an instance of the server object _server = New Leadtools.MediaStreaming.Server() ' retrieve a copy of the Network Properties Dim props As NetworkProperties = _server.GetNetworkProperties() Dim strStore As String = "MY" Dim strCertificate As String = "LEAD Media Streaming Server" ' Friendly Name of the certificate we want to find. ' find the certificate name in the specified store, and get the hash Dim hash As Byte() = Nothing Dim certstore As System.Security.Cryptography.X509Certificates.X509Store certstore = New System.Security.Cryptography.X509Certificates.X509Store(strStore, System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine) Dim flag As System.Security.Cryptography.X509Certificates.OpenFlags flag = System.Security.Cryptography.X509Certificates.OpenFlags.OpenExistingOnly Or System.Security.Cryptography.X509Certificates.OpenFlags.ReadWrite certstore.Open(flag) For Each certificate As System.Security.Cryptography.X509Certificates.X509Certificate2 In certstore.Certificates If certificate.FriendlyName = strCertificate Then hash = certificate.GetCertHash() Exit For End If Next certificate If Not hash Is Nothing AndAlso hash.Length > 0 Then ' change the properties props.SSLPort = 6968 props.SSLCertificateStore = strStore props.SSLCertificateHash = hash ' copy the Network Properties to the server _server.SetNetworkProperties(props) _result = True End If Catch e1 As Exception _result = False End Try End Sub
using Leadtools; using Leadtools.MediaStreaming; public Server _server = null; public bool _result = false; public void SetNetworkSSLPropertiesExample() { try { // create an instance of the server object _server = new Leadtools.MediaStreaming.Server(); // retrieve a copy of the Network Properties NetworkProperties props = _server.GetNetworkProperties(); string strStore = "MY"; string strCertificate = "LEAD Media Streaming Server"; // Friendly Name of the certificate we want to find. // find the certificate name in the specified store, and get the hash byte[] hash = null; System.Security.Cryptography.X509Certificates.X509Store certstore; certstore = new System.Security.Cryptography.X509Certificates.X509Store(strStore, System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine); System.Security.Cryptography.X509Certificates.OpenFlags flag; flag = System.Security.Cryptography.X509Certificates.OpenFlags.OpenExistingOnly | System.Security.Cryptography.X509Certificates.OpenFlags.ReadWrite; certstore.Open(flag); foreach (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate in certstore.Certificates) { if (certificate.FriendlyName == strCertificate) { hash = certificate.GetCertHash(); break; } } if (hash != null && hash.Length > 0) { // change the properties props.SSLPort = 6968; props.SSLCertificateStore = strStore; props.SSLCertificateHash = hash; // copy the Network Properties to the server _server.SetNetworkProperties(props); _result = true; } } catch (Exception) { _result = false; } }