GraphQL: Use cert from store
This commit is contained in:
@@ -11,14 +11,14 @@ Public Class GraphQLInterface
|
||||
Private _baseUrl As String
|
||||
Private _userEmail As String
|
||||
Private _userPassword As String
|
||||
Private _certificate As X509Certificate
|
||||
Private _certificate As X509Certificate2
|
||||
Private _cookieJar As CookieContainer
|
||||
Private _Encoding As New UTF8Encoding
|
||||
|
||||
Public Property Proxy As WebProxy
|
||||
Public Property Credentials As NetworkCredential
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, BaseUrl As String, Email As String, Password As String, CertificateFile As String, CertificatePassword As String)
|
||||
Public Sub New(LogConfig As LogConfig, BaseUrl As String, Email As String, Password As String, CertificateFingerprint As String)
|
||||
Try
|
||||
_logConfig = LogConfig
|
||||
_logger = LogConfig.GetLogger()
|
||||
@@ -26,18 +26,29 @@ Public Class GraphQLInterface
|
||||
_userEmail = Email
|
||||
_userPassword = Password
|
||||
|
||||
_certificate = New X509Certificate2(CertificateFile, CertificatePassword, X509KeyStorageFlags.UserKeySet)
|
||||
|
||||
Dim oStore As New X509Store(StoreName.My, StoreLocation.CurrentUser)
|
||||
oStore.Open(OpenFlags.ReadOnly)
|
||||
|
||||
|
||||
_logger.Debug("Available Certificates ({0}):", oStore.Certificates.Count)
|
||||
|
||||
For Each oCert In oStore.Certificates
|
||||
_logger.Debug("FriendlyName: {0}", oCert.FriendlyName)
|
||||
_logger.Debug("IssuerName: {0}", oCert.IssuerName.Name)
|
||||
_logger.Debug("SubjectName: {0}", oCert.SubjectName.Name)
|
||||
_logger.Debug("Fingerprint: {0}", oCert.Thumbprint)
|
||||
Next
|
||||
|
||||
_logger.Debug("Looking for Certificate with Fingerprint [{0}]", CertificateFingerprint)
|
||||
|
||||
Dim oFoundCerts = oStore.Certificates.Find(X509FindType.FindByThumbprint, CertificateFingerprint, False)
|
||||
|
||||
If oFoundCerts.Count = 0 Then
|
||||
MsgBox($"Das Zertifikat mit dem Fingerprint [{CertificateFingerprint}] konnte nicht im Store [{oStore.Name}] gefunden werden!")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
_certificate = oFoundCerts.Item(0)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
|
||||
Reference in New Issue
Block a user