what is the correct way to cancel multiple tasks in c#

Yeah, what you said about using a single CancellationToken is correct. You can create a single CancellationTokenSource and use its CancellationToken for all of the tasks. Your tasks should check the token regularly for cancellation. For example: const int NUM_TASKS = 4; CancellationTokenSource cts = new CancellationTokenSource(); CancellationToken ct = cts.Token; Task[] tasks = new … Read more

How can I create a PFX file from a Java Keystore?

From Java 6 onwards, keytool has an -importkeystore option, which should be able to convert a JKS store into a PKCS#12 store (.p12/.pfx): keytool -importkeystore -srckeystore thekeystore.jks \ -srcstoretype JKS \ -destkeystore thekeystore.pfx \ -deststoretype PKCS12 It will ask you to enter a password for source and destination (jks, pfx) files

How to create a valid, self-signed X509Certificate2 programmatically, not loading from file in .NET Core

I found this other SO question that put me on the right track. Certificates API was added to .Net Core on 2.0 version. I have a function like the next one to create self signed certificates that I later import into My store to use them on IIS. private X509Certificate2 buildSelfSignedServerCertificate() { SubjectAlternativeNameBuilder sanBuilder = … Read more

How to retrieve certificates from a pfx file with c#?

You should be able to get a collection object containing the certs in your .pfx file by using the X509Certificate2Collection class… here’s some C# example code: string certPath = <YOUR PFX FILE PATH>; string certPass = <YOUR PASSWORD>; // Create a collection object and populate it using the PFX file X509Certificate2Collection collection = new X509Certificate2Collection(); … Read more

Waiting on a Task with a OnlyOnFaulted Continuation causes an AggregateException

You’re not waiting on a task with an OnlyOnFaulted continuation – you’re waiting on that continuation (returned by ContinueWith). The continuation is never going to fire because the original task returned normally, so it’s acting as if it were cancelled. Makes sense to me. I suspect you want to create the task, add the continuation, … Read more

How to create a snk from pfx / cer?

A little clarification about your mentioned file types: .cer-files are X.509 Certificates .pfx-files are encrypted X.509 Certificates using a password-based symmetric key, also see PKCS #12 (Wikipedia) .snk-files only contain the RSA key (public/private or public only) It doesn’t matter if you sign an assembly using .pfx-files or .snk-files, it will get strong named either … Read more

How to check expiry date of pfx file?

As explained here, you can review the information of the certificate before import it using: certutil -dump YourCertificate.pfx If you want to run this from Visual Studio you can do this: Go to Tools > External Tools > Add Set the required info: Name=CertUtil Command=C:\Windows\System32\certutil.exe Arguments=-p YourPass -dump $(ItemPath). Check Use output window. With this … Read more

“An internal error occurred.” when loading pfx file with X509Certificate2

Use the local computer store for the private key: X509Certificate2 cert = new X509Certificate2(“myhost.pfx”, “pass”, X509KeyStorageFlags.MachineKeySet); MachineKeySet is described as “private keys are stored in the local computer store rather than the current user store”. The default with no flags is to place in the user store. Even though you are reading the certificate from … Read more

Converting pfx to pem using openssl

Another perspective for doing it on Linux… here is how to do it so that the resulting single file contains the decrypted private key so that something like HAProxy can use it without prompting you for passphrase. openssl pkcs12 -in file.pfx -out file.pem -nodes Then you can configure HAProxy to use the file.pem file. This … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)