r/visualbasic • • Feb 27 '19

Need help with my code

I am a non-user. I have basic to minimal knowledge and I need some help in writing code. Hence I will list down every fact I know about the issue and maybe one of you can help me with this.

I have been asked to work on X509 certificate code. Currently, we have a code where the encryption happens on the Hard drive of the user and we need it to happen in cache or in the backend itself. This is the code below. There was some mention of BitArrays and how we would need to use it. If the code below makes sense then please help me out!

If (AppSettings("Second Version") = "yes") Then

Cerf.Import (AppSettings("CertificatePath").ToString(), AppSettings("CertificatePassword").ToString(), X509KeyStorageFlags.DefaultKeySet)

myws.url = String.concat (AppSettings ("DomainName").ToString(), xxxxxxxx.asmx)

myws.ClientCertificates.add(Cerf)

End If

If additional details are needed, please comment below and I can get details from my superior. Because of my ignorance, I dont really know what to ask him at this point.

Thanks for reading.

5 Upvotes

2 comments sorted by

1

u/andrewsmd87 Web Specialist Feb 27 '19

I'm not really clear on what you're trying to accomplish, but does this help?

Dim collection = New X509Certificate2Collection()

collection.Import(.FileName, "xxxxxxx", X509KeyStorageFlags.UserKeySet)

Dim store = New X509Store(StoreName.My, StoreLocation.CurrentUser)

store.Open(OpenFlags.ReadWrite)

Try

For Each certificate As X509Certificate2 In collection

    store.Add(certificate)

Next

Finally

store.Close()

End Try

1

u/Man_of_steels Feb 27 '19

DO you mind if I PM you for some more questions?