J
John Wright
I have a x509Certificate that I exported and I am using for testing called
wsTest.cer.pfx. I want to use this cert to send a public key to anyone who
requests it, and then use the private key to decrypt any incoming messages.
In the code below you can see I can grab the publickey string from this cert
and pass it back to the client. I can also create a
RSACryptoServiceProvider from the cert.private key. This is all good and
fine. What I am trying to do, is write the client code that could
encrypt/decrypt messages from the server using the public key, and write
code that would encrypt/decrypt using the private key. Anyone have code
that would do this. I have looked on google with little success.
John
Dim cert As New X509Certificate2("[cert location]", "password")
Dim rsa As RSACryptoServiceProvider = CType(cert.PrivateKey,
RSACryptoServiceProvider)
With cert
TextBox4.Text = .GetKeyAlgorithm
TextBox6.Text = .GetCertHashString & vbCrLf
TextBox5.Text = .PrivateKey.ToString
TextBox6.Text &= .GetPublicKeyString
TextBox5.Text = .GetRawCertDataString
MsgBox(.HasPrivateKey)
End With
wsTest.cer.pfx. I want to use this cert to send a public key to anyone who
requests it, and then use the private key to decrypt any incoming messages.
In the code below you can see I can grab the publickey string from this cert
and pass it back to the client. I can also create a
RSACryptoServiceProvider from the cert.private key. This is all good and
fine. What I am trying to do, is write the client code that could
encrypt/decrypt messages from the server using the public key, and write
code that would encrypt/decrypt using the private key. Anyone have code
that would do this. I have looked on google with little success.
John
Dim cert As New X509Certificate2("[cert location]", "password")
Dim rsa As RSACryptoServiceProvider = CType(cert.PrivateKey,
RSACryptoServiceProvider)
With cert
TextBox4.Text = .GetKeyAlgorithm
TextBox6.Text = .GetCertHashString & vbCrLf
TextBox5.Text = .PrivateKey.ToString
TextBox6.Text &= .GetPublicKeyString
TextBox5.Text = .GetRawCertDataString
MsgBox(.HasPrivateKey)
End With