GraphQL: Use cert from store
This commit is contained in:
parent
874cf74796
commit
3ece4e6222
@ -2,6 +2,7 @@
|
|||||||
Public Property ConnectionString As String = "Server=SERVER;Database=DATABASE;User Id=sa;Password=dd"
|
Public Property ConnectionString As String = "Server=SERVER;Database=DATABASE;User Id=sa;Password=dd"
|
||||||
Public Property CertificateFile As String = "C:\Path\To\Cert.pfx"
|
Public Property CertificateFile As String = "C:\Path\To\Cert.pfx"
|
||||||
Public Property CertificatePass As String = "CertificatePassword"
|
Public Property CertificatePass As String = "CertificatePassword"
|
||||||
|
Public Property CertificateFingerprint As String = ""
|
||||||
Public Property Email As String = "foo.bar@wisag.de"
|
Public Property Email As String = "foo.bar@wisag.de"
|
||||||
Public Property Password As String = "Password"
|
Public Property Password As String = "Password"
|
||||||
Public Property BaseUrl As String = "https://data.api.wisag.de:8443"
|
Public Property BaseUrl As String = "https://data.api.wisag.de:8443"
|
||||||
|
|||||||
86
GUIs.Test.GraphQLTest/frmMain.Designer.vb
generated
86
GUIs.Test.GraphQLTest/frmMain.Designer.vb
generated
@ -40,6 +40,9 @@ Partial Class frmMain
|
|||||||
Me.Label7 = New System.Windows.Forms.Label()
|
Me.Label7 = New System.Windows.Forms.Label()
|
||||||
Me.TabControl1 = New System.Windows.Forms.TabControl()
|
Me.TabControl1 = New System.Windows.Forms.TabControl()
|
||||||
Me.pageRaw = New System.Windows.Forms.TabPage()
|
Me.pageRaw = New System.Windows.Forms.TabPage()
|
||||||
|
Me.pageQuery = New System.Windows.Forms.TabPage()
|
||||||
|
Me.txtQuery = New System.Windows.Forms.TextBox()
|
||||||
|
Me.txtOperation = New System.Windows.Forms.TextBox()
|
||||||
Me.btnLogin = New System.Windows.Forms.Button()
|
Me.btnLogin = New System.Windows.Forms.Button()
|
||||||
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
|
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
|
||||||
Me.txtProxyHost = New System.Windows.Forms.TextBox()
|
Me.txtProxyHost = New System.Windows.Forms.TextBox()
|
||||||
@ -50,9 +53,8 @@ Partial Class frmMain
|
|||||||
Me.Label10 = New System.Windows.Forms.Label()
|
Me.Label10 = New System.Windows.Forms.Label()
|
||||||
Me.txtProxyPort = New System.Windows.Forms.TextBox()
|
Me.txtProxyPort = New System.Windows.Forms.TextBox()
|
||||||
Me.Label11 = New System.Windows.Forms.Label()
|
Me.Label11 = New System.Windows.Forms.Label()
|
||||||
Me.pageQuery = New System.Windows.Forms.TabPage()
|
Me.txtCertFingerprint = New System.Windows.Forms.TextBox()
|
||||||
Me.txtQuery = New System.Windows.Forms.TextBox()
|
Me.Label12 = New System.Windows.Forms.Label()
|
||||||
Me.txtOperation = New System.Windows.Forms.TextBox()
|
|
||||||
Me.TabControl1.SuspendLayout()
|
Me.TabControl1.SuspendLayout()
|
||||||
Me.pageRaw.SuspendLayout()
|
Me.pageRaw.SuspendLayout()
|
||||||
Me.pageQuery.SuspendLayout()
|
Me.pageQuery.SuspendLayout()
|
||||||
@ -165,16 +167,16 @@ Partial Class frmMain
|
|||||||
'
|
'
|
||||||
'txtConnectionString
|
'txtConnectionString
|
||||||
'
|
'
|
||||||
Me.txtConnectionString.Location = New System.Drawing.Point(106, 136)
|
Me.txtConnectionString.Location = New System.Drawing.Point(106, 167)
|
||||||
Me.txtConnectionString.Multiline = True
|
Me.txtConnectionString.Multiline = True
|
||||||
Me.txtConnectionString.Name = "txtConnectionString"
|
Me.txtConnectionString.Name = "txtConnectionString"
|
||||||
Me.txtConnectionString.Size = New System.Drawing.Size(338, 98)
|
Me.txtConnectionString.Size = New System.Drawing.Size(338, 67)
|
||||||
Me.txtConnectionString.TabIndex = 1
|
Me.txtConnectionString.TabIndex = 1
|
||||||
'
|
'
|
||||||
'Label6
|
'Label6
|
||||||
'
|
'
|
||||||
Me.Label6.AutoSize = True
|
Me.Label6.AutoSize = True
|
||||||
Me.Label6.Location = New System.Drawing.Point(12, 139)
|
Me.Label6.Location = New System.Drawing.Point(12, 167)
|
||||||
Me.Label6.Name = "Label6"
|
Me.Label6.Name = "Label6"
|
||||||
Me.Label6.Size = New System.Drawing.Size(88, 13)
|
Me.Label6.Size = New System.Drawing.Size(88, 13)
|
||||||
Me.Label6.TabIndex = 2
|
Me.Label6.TabIndex = 2
|
||||||
@ -219,6 +221,36 @@ Partial Class frmMain
|
|||||||
Me.pageRaw.Text = "Raw GraphQL Result"
|
Me.pageRaw.Text = "Raw GraphQL Result"
|
||||||
Me.pageRaw.UseVisualStyleBackColor = True
|
Me.pageRaw.UseVisualStyleBackColor = True
|
||||||
'
|
'
|
||||||
|
'pageQuery
|
||||||
|
'
|
||||||
|
Me.pageQuery.Controls.Add(Me.txtQuery)
|
||||||
|
Me.pageQuery.Controls.Add(Me.txtOperation)
|
||||||
|
Me.pageQuery.Location = New System.Drawing.Point(4, 22)
|
||||||
|
Me.pageQuery.Name = "pageQuery"
|
||||||
|
Me.pageQuery.Padding = New System.Windows.Forms.Padding(3)
|
||||||
|
Me.pageQuery.Size = New System.Drawing.Size(464, 348)
|
||||||
|
Me.pageQuery.TabIndex = 1
|
||||||
|
Me.pageQuery.Text = "Custom Query"
|
||||||
|
Me.pageQuery.UseVisualStyleBackColor = True
|
||||||
|
'
|
||||||
|
'txtQuery
|
||||||
|
'
|
||||||
|
Me.txtQuery.Dock = System.Windows.Forms.DockStyle.Fill
|
||||||
|
Me.txtQuery.Font = New System.Drawing.Font("Consolas", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
||||||
|
Me.txtQuery.Location = New System.Drawing.Point(3, 23)
|
||||||
|
Me.txtQuery.Multiline = True
|
||||||
|
Me.txtQuery.Name = "txtQuery"
|
||||||
|
Me.txtQuery.Size = New System.Drawing.Size(458, 322)
|
||||||
|
Me.txtQuery.TabIndex = 0
|
||||||
|
'
|
||||||
|
'txtOperation
|
||||||
|
'
|
||||||
|
Me.txtOperation.Dock = System.Windows.Forms.DockStyle.Top
|
||||||
|
Me.txtOperation.Location = New System.Drawing.Point(3, 3)
|
||||||
|
Me.txtOperation.Name = "txtOperation"
|
||||||
|
Me.txtOperation.Size = New System.Drawing.Size(458, 20)
|
||||||
|
Me.txtOperation.TabIndex = 1
|
||||||
|
'
|
||||||
'btnLogin
|
'btnLogin
|
||||||
'
|
'
|
||||||
Me.btnLogin.Location = New System.Drawing.Point(724, 386)
|
Me.btnLogin.Location = New System.Drawing.Point(724, 386)
|
||||||
@ -299,35 +331,21 @@ Partial Class frmMain
|
|||||||
Me.Label11.TabIndex = 2
|
Me.Label11.TabIndex = 2
|
||||||
Me.Label11.Text = "Proxy Port"
|
Me.Label11.Text = "Proxy Port"
|
||||||
'
|
'
|
||||||
'pageQuery
|
'txtCertFingerprint
|
||||||
'
|
'
|
||||||
Me.pageQuery.Controls.Add(Me.txtQuery)
|
Me.txtCertFingerprint.Location = New System.Drawing.Point(106, 136)
|
||||||
Me.pageQuery.Controls.Add(Me.txtOperation)
|
Me.txtCertFingerprint.Name = "txtCertFingerprint"
|
||||||
Me.pageQuery.Location = New System.Drawing.Point(4, 22)
|
Me.txtCertFingerprint.Size = New System.Drawing.Size(338, 20)
|
||||||
Me.pageQuery.Name = "pageQuery"
|
Me.txtCertFingerprint.TabIndex = 1
|
||||||
Me.pageQuery.Padding = New System.Windows.Forms.Padding(3)
|
|
||||||
Me.pageQuery.Size = New System.Drawing.Size(464, 348)
|
|
||||||
Me.pageQuery.TabIndex = 1
|
|
||||||
Me.pageQuery.Text = "Custom Query"
|
|
||||||
Me.pageQuery.UseVisualStyleBackColor = True
|
|
||||||
'
|
'
|
||||||
'txtQuery
|
'Label12
|
||||||
'
|
'
|
||||||
Me.txtQuery.Dock = System.Windows.Forms.DockStyle.Fill
|
Me.Label12.AutoSize = True
|
||||||
Me.txtQuery.Font = New System.Drawing.Font("Consolas", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
Me.Label12.Location = New System.Drawing.Point(12, 139)
|
||||||
Me.txtQuery.Location = New System.Drawing.Point(3, 23)
|
Me.Label12.Name = "Label12"
|
||||||
Me.txtQuery.Multiline = True
|
Me.Label12.Size = New System.Drawing.Size(78, 13)
|
||||||
Me.txtQuery.Name = "txtQuery"
|
Me.Label12.TabIndex = 2
|
||||||
Me.txtQuery.Size = New System.Drawing.Size(458, 322)
|
Me.Label12.Text = "Cert Fingerprint"
|
||||||
Me.txtQuery.TabIndex = 0
|
|
||||||
'
|
|
||||||
'txtOperation
|
|
||||||
'
|
|
||||||
Me.txtOperation.Dock = System.Windows.Forms.DockStyle.Top
|
|
||||||
Me.txtOperation.Location = New System.Drawing.Point(3, 3)
|
|
||||||
Me.txtOperation.Name = "txtOperation"
|
|
||||||
Me.txtOperation.Size = New System.Drawing.Size(458, 20)
|
|
||||||
Me.txtOperation.TabIndex = 1
|
|
||||||
'
|
'
|
||||||
'frmMain
|
'frmMain
|
||||||
'
|
'
|
||||||
@ -339,6 +357,7 @@ Partial Class frmMain
|
|||||||
Me.Controls.Add(Me.cmbQuery)
|
Me.Controls.Add(Me.cmbQuery)
|
||||||
Me.Controls.Add(Me.Label7)
|
Me.Controls.Add(Me.Label7)
|
||||||
Me.Controls.Add(Me.Label6)
|
Me.Controls.Add(Me.Label6)
|
||||||
|
Me.Controls.Add(Me.Label12)
|
||||||
Me.Controls.Add(Me.Label5)
|
Me.Controls.Add(Me.Label5)
|
||||||
Me.Controls.Add(Me.Label4)
|
Me.Controls.Add(Me.Label4)
|
||||||
Me.Controls.Add(Me.Label10)
|
Me.Controls.Add(Me.Label10)
|
||||||
@ -349,6 +368,7 @@ Partial Class frmMain
|
|||||||
Me.Controls.Add(Me.Label8)
|
Me.Controls.Add(Me.Label8)
|
||||||
Me.Controls.Add(Me.Label1)
|
Me.Controls.Add(Me.Label1)
|
||||||
Me.Controls.Add(Me.txtConnectionString)
|
Me.Controls.Add(Me.txtConnectionString)
|
||||||
|
Me.Controls.Add(Me.txtCertFingerprint)
|
||||||
Me.Controls.Add(Me.txtCertPass)
|
Me.Controls.Add(Me.txtCertPass)
|
||||||
Me.Controls.Add(Me.txtCertFile)
|
Me.Controls.Add(Me.txtCertFile)
|
||||||
Me.Controls.Add(Me.txtProxyPass)
|
Me.Controls.Add(Me.txtProxyPass)
|
||||||
@ -403,4 +423,6 @@ Partial Class frmMain
|
|||||||
Friend WithEvents pageQuery As TabPage
|
Friend WithEvents pageQuery As TabPage
|
||||||
Friend WithEvents txtQuery As TextBox
|
Friend WithEvents txtQuery As TextBox
|
||||||
Friend WithEvents txtOperation As TextBox
|
Friend WithEvents txtOperation As TextBox
|
||||||
|
Friend WithEvents txtCertFingerprint As TextBox
|
||||||
|
Friend WithEvents Label12 As Label
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -56,8 +56,11 @@ Public Class frmMain
|
|||||||
txtBaseUrl.Text = _Config.Config.BaseUrl
|
txtBaseUrl.Text = _Config.Config.BaseUrl
|
||||||
txtUsername.Text = _Config.Config.Email
|
txtUsername.Text = _Config.Config.Email
|
||||||
txtPassword.Text = _Config.Config.Password
|
txtPassword.Text = _Config.Config.Password
|
||||||
|
|
||||||
txtCertFile.Text = _Config.Config.CertificateFile
|
txtCertFile.Text = _Config.Config.CertificateFile
|
||||||
txtCertPass.Text = _Config.Config.CertificatePass
|
txtCertPass.Text = _Config.Config.CertificatePass
|
||||||
|
txtCertFingerprint.Text = _Config.Config.CertificateFingerprint
|
||||||
|
|
||||||
txtConnectionString.Text = _Config.Config.ConnectionString
|
txtConnectionString.Text = _Config.Config.ConnectionString
|
||||||
txtProxyHost.Text = _Config.Config.ProxyHost
|
txtProxyHost.Text = _Config.Config.ProxyHost
|
||||||
txtProxyPort.Text = _Config.Config.ProxyPort
|
txtProxyPort.Text = _Config.Config.ProxyPort
|
||||||
@ -81,8 +84,7 @@ Public Class frmMain
|
|||||||
txtBaseUrl.Text,
|
txtBaseUrl.Text,
|
||||||
txtUsername.Text,
|
txtUsername.Text,
|
||||||
txtPassword.Text,
|
txtPassword.Text,
|
||||||
txtCertFile.Text,
|
txtCertFingerprint.Text)
|
||||||
txtCertPass.Text)
|
|
||||||
|
|
||||||
If _Config.Config.HasProxySet() And _Config.Config.HasProxyCredentialsSet() Then
|
If _Config.Config.HasProxySet() And _Config.Config.HasProxyCredentialsSet() Then
|
||||||
Dim oURI As New Uri($"http://{_Config.Config.ProxyHost}:{_Config.Config.ProxyPort}")
|
Dim oURI As New Uri($"http://{_Config.Config.ProxyHost}:{_Config.Config.ProxyPort}")
|
||||||
@ -210,8 +212,11 @@ Public Class frmMain
|
|||||||
Try
|
Try
|
||||||
_Config.Config.ConnectionString = txtConnectionString.Text
|
_Config.Config.ConnectionString = txtConnectionString.Text
|
||||||
_Config.Config.BaseUrl = txtBaseUrl.Text
|
_Config.Config.BaseUrl = txtBaseUrl.Text
|
||||||
|
|
||||||
_Config.Config.CertificateFile = txtCertFile.Text
|
_Config.Config.CertificateFile = txtCertFile.Text
|
||||||
_Config.Config.CertificatePass = txtCertPass.Text
|
_Config.Config.CertificatePass = txtCertPass.Text
|
||||||
|
_Config.Config.CertificateFingerprint = txtCertFingerprint.Text
|
||||||
|
|
||||||
_Config.Config.Email = txtUsername.Text
|
_Config.Config.Email = txtUsername.Text
|
||||||
_Config.Config.Password = txtPassword.Text
|
_Config.Config.Password = txtPassword.Text
|
||||||
_Config.Config.ProxyHost = txtProxyHost.Text
|
_Config.Config.ProxyHost = txtProxyHost.Text
|
||||||
|
|||||||
@ -11,14 +11,14 @@ Public Class GraphQLInterface
|
|||||||
Private _baseUrl As String
|
Private _baseUrl As String
|
||||||
Private _userEmail As String
|
Private _userEmail As String
|
||||||
Private _userPassword As String
|
Private _userPassword As String
|
||||||
Private _certificate As X509Certificate
|
Private _certificate As X509Certificate2
|
||||||
Private _cookieJar As CookieContainer
|
Private _cookieJar As CookieContainer
|
||||||
Private _Encoding As New UTF8Encoding
|
Private _Encoding As New UTF8Encoding
|
||||||
|
|
||||||
Public Property Proxy As WebProxy
|
Public Property Proxy As WebProxy
|
||||||
Public Property Credentials As NetworkCredential
|
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
|
Try
|
||||||
_logConfig = LogConfig
|
_logConfig = LogConfig
|
||||||
_logger = LogConfig.GetLogger()
|
_logger = LogConfig.GetLogger()
|
||||||
@ -26,18 +26,29 @@ Public Class GraphQLInterface
|
|||||||
_userEmail = Email
|
_userEmail = Email
|
||||||
_userPassword = Password
|
_userPassword = Password
|
||||||
|
|
||||||
_certificate = New X509Certificate2(CertificateFile, CertificatePassword, X509KeyStorageFlags.UserKeySet)
|
|
||||||
|
|
||||||
Dim oStore As New X509Store(StoreName.My, StoreLocation.CurrentUser)
|
Dim oStore As New X509Store(StoreName.My, StoreLocation.CurrentUser)
|
||||||
oStore.Open(OpenFlags.ReadOnly)
|
oStore.Open(OpenFlags.ReadOnly)
|
||||||
|
|
||||||
|
|
||||||
_logger.Debug("Available Certificates ({0}):", oStore.Certificates.Count)
|
_logger.Debug("Available Certificates ({0}):", oStore.Certificates.Count)
|
||||||
|
|
||||||
For Each oCert In oStore.Certificates
|
For Each oCert In oStore.Certificates
|
||||||
_logger.Debug("FriendlyName: {0}", oCert.FriendlyName)
|
_logger.Debug("FriendlyName: {0}", oCert.FriendlyName)
|
||||||
_logger.Debug("IssuerName: {0}", oCert.IssuerName.Name)
|
_logger.Debug("IssuerName: {0}", oCert.IssuerName.Name)
|
||||||
_logger.Debug("SubjectName: {0}", oCert.SubjectName.Name)
|
_logger.Debug("SubjectName: {0}", oCert.SubjectName.Name)
|
||||||
|
_logger.Debug("Fingerprint: {0}", oCert.Thumbprint)
|
||||||
Next
|
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
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user