Update 2019/11/14: As well as year before we will do extra slots again. We will start from slot for [Dec 18 – Dec 24] week, and when they are filled I will add slots for [Dec 11 – Dec 17], then for [Dec 1 – Dec 10] and finally [Dec 25-Dec 31].
F# Advent Calendar is a long tradition in F# community
Advent 2019 is coming, this year we have 56 free slots. Please join, reserve a slot and spread your thoughts and love to F# with the community.
This year I completely forgot to celebrate 7th birthday of F# Weekly. The very first F# Weekly #43, 2012 was published at 29/10/2012. Since than every 43th edition was an anniversary edition. Help me please celebrate the date – book your slot in #FsAdvent and deliver post in time!
Join F# Advent Calendar today!
Rules
Choose F# related topic for your blog post and reserve the slot on Twitter or leave a comment to this post. Please note that you do not have to announce the topic until the date (but you can).
Prepare a blog post in English.
Publish your post on a specified date (according to the calendar).
Post the link to your post on Twitter with hashtags #fsharp and #FsAdvent.
The Fabulous framework has just received a huge update to the code generation mechanism by @Tim_Lariviere. CodeGen is now decoupled from Xamarin Forms, opening the door for new frameworks. Great work Tim 🎉 https://t.co/NPfCguxiHe#fsharp
Really interesting thread from @dsyme on F# v C#, the perf impact of using tuples (value types), CLR NGEN support for generic structs and more https://t.co/3Ed6WphYxv
Just in case you missed it: DotNet SDK v3 is out! It adds local dotnet tools. Naturally, @fsharpMake already supports them via `dotnet tool install fake-cli` (see docs). If you already using v3 or upgrading is an option please try it and report back!https://t.co/bFDlibkAJK
Join the EAP (Early Access Program) for Rider 2019.3 and preview: – Better performance – Docker-compose debugging – Initial MongoDB support – Improved support for C# 8 – New Type Name Hints – Profile .NET Core on Linux and macOS Intrigued? Learn more at https://t.co/aIzLpqmfXNpic.twitter.com/SbPLq1WiVC
Very nice article on refactoring (in Haskell) to a cleaner design while improving type safety as well. The techniques could equally well be applied to F#, OCaml, Elm, etc.https://t.co/E3Dy4SYpcc
I've just released new version of @IonideProject. It includes: * Fix for recent `.fsx` problems (@ChetHusk) * Experimental `dotnet fsi` support * Experimental Fantomas support (Format document command) (@verdonckflorian) * Fix for tooltip formatting (@7sharp9_exhumed)#fsharppic.twitter.com/oGcdycylES
HashiCorp Vault is a tool for secrets management, encryption as a service, and privileged access management. It is quite popular nowadays, especially if you own your own infrastructure, private cloud or just cannot store your secrets using Key Vault services provided by Azure/AWS/GCP.
I assume that you already have one up and running instance of HashiCorp Vault, otherwise you may install one using official Installing Vault guide.
Why TLS certificate authentication?
Vault supports many Auth Methods. But what if you are still deploying your app on plain old Windows Server VMs or develop SharePoint application (like I am 😝).
The challenge in this case, that you have to authenticate in Vault in order to get a secret. This means that we need to choose auth method that protects our auth secrets from an accident IT guys who may login on the VM (or malicious code that may find it on file system)
TLS Certificate Auth is a good solution candidate, because we can install certificate into windows certificate store, protect private key (mark it as not-exportable) and even specify list of service accounts, allowed to use this certificate for authentication.
TLS certificate generation
I will be using ssh command on my macOS for certificate generation and Vault configuration, but you can repeat the same step from Window for sure.
For our needs we will use self-signed certificate. You can generate one using OpenSSL. If you do not have OpenSSL installed, you can install from Homebrew.
brew install openssl
First of all we generate private key (it is highly secured, do not share it)
openssl genrsa 2048 > vault_private.pem
Then we generate public part of the key in .pem format (.pem file will be uploaded to Vault for client validation during authentication)
Answer all questions properly, it will help you identify this certificate in future (I’ve created certificate that is valid for 365 days, but you should follow security standards defined in you company).
Note: Common Name cannot be empty, otherwise you will not be able to use this certificate to retrieve the secret (Vault returns ‘missing name in alias’ error). Thank you Vadzim Makarchyk for this note.
The final step is to archive both parts in .pfx format (.pfx file will be deployed into Windows Server certificate store on all machines from where our code should have access to Vault)
I uses Enterprise version of Vault that is used by several teams, that it why I also specify namespace (aka folder for my secrets)
VAULT_NAMESPACE=dev/my-teamexport VAULT_NAMESPACE
I am lazy to properly setup certificates for Vault CLI, that is why I skip certificate validation (never repeat it in production 😉)
VAULT_SKIP_VERIFY=trueexport VAULT_SKIP_VERIFY
We are almost ready to login. The easiest option is to login using Web UI and then reuse issued token in the terminal. Login using your favorite browser, pass authentication and copy token in buffer.
vault login s.fJTY5S51oIfXKnBAG3Qq5eWp.9GKyY
That is it! Token is saved into ~/.vault-token and CLI is ready to use!
Key/Value secret engine creation
Vault supports multiple Secret Engines, but for our demo we create simple Key/Value storage for secrets (for example to store logins and passwords)
vault secrets enable -path=kv kv
This command enable key/value engine (V1) and name kv (-path param)
NOTE: The kv secrets engine has two versions: kv and kv-v2. To enable versioned kv secrets engine, pass kv-v2 instead.
Engine is ready, but it is empty – let’s fix it.
vault write kv/my-secret value="s3c(eT"
This command effectively creates my-secret secret inside kv secret engine and store one key/value pair inside value=”s3c(eT”
ACL Policy creation
Secret engine is secured, nobody (except you, admin) has access to secrets. We need to create rules/policy that define what access we want to provide. Create new files policy-file.hcl and put following content inside.
path "kv/*" { capabilities = ["read", "list"]}
This policy allows to read and list all secrets inside kv secret engine. All users with this policy will be able to read secrets from our engine. Read more about policies.
Write this policy to the server (and name it policy-name)
vault policy write policy-name policy-file.hcl
TLS Certificates – Auth Method
The last step is to assign this policy. But we want to assign it to all clients authenticated in Vault using TLS certificate created by us earlier.
Fist of all we need to enable certificate authentication in our namespace
vault auth enable cert
and create certificate auth in Vault (name it app), assign policy-name to it and upload the public part of generated key (vault_public.pem)
That is it! Vault is configured and waiting for first connection.
TLS certificate deployment
TLS certificate allows us to deploy it to certain set of machines that should have access to the Vault and then specify which accounts (on these machines) may use it for authentication.
On the screenshot you see the step that imports certificate on all target machines with tag SharePoint (in my case) to LocalMachine certificate store to My/Personal store, mark private-key as not exportable and provide access to private key to 2 service accounts.
If your deployment is not automated, you may script the same steps using PowerShell and run it on all machines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
If you are brave, you can click it even manually! 🙈
Double click on vault.pfx file and choose LocalMachine store location
Click Next, Next and type password used during *.pfx creation and Next again.
Choose Personal certificate store.
Click Next, Finish, OK – your certificated in the store!
Execute mmc (Microsoft Managed Console) from start menu.
File -> Add/Remove Snap-in …
Certificate, Add, Computer account and click Next & Ok
Find our certificate and click Manage Private Keys…
On this screen you can manage the list of accounts that will be able to use this certificate for authentication on the current machine.
.NET client application
Vault is ready, machine is ready (service account / current user is allowed to use certificate from the LocalMachine/Personal store). Few lines of code are separating us from success 😊.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
VaultSecretProvider find X509 certificate in StoreName.My / StoreLocation.LocalMachine, then create CertAuthMethodInfo using certificate and VaultClient that X-Vault-Namespace header to each request with vaultNamespace name.
Using configured instance of VaultClient we can request our secret from Vault _vaultClient.V1.Secrets.KeyValue.V1.ReadSecretAsync(path, mountPoint) specifying path to the secret and mountPoint (name of secret engine).
We are ready to call and receive secrets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
At #dotNETConf we showed a sample tool that helps convert classic .csproj to newer SDK style .csproj used in .NET Core. The sample code is now available: https://t.co/aWOl11D6Z4. It will never work 100% but we hope the sample helps you along the way.
Thanks to everyone who came to my talk about perf tooling in .net core 3 at #openfsharp! You can find the slides and sample code at https://t.co/bplxgM6Sge
Version 32 of @FSCompService is out! It contains all the features and fixes in F# 4.7 that came out last week! Over the next few days we'll be working with maintainers to get it into FSAC/@IonideProject and all the other usual suspects. Packages here: https://t.co/uX83r76ib3
#FSharp Nation! Put it in your calendar and start planning your trip to Washington DC! Capitol FSharp will be on February 29 2020. Details coming soon!
83 speakers are polishing their demos. The 77 session agenda is set to roll for over 40 hours. 200+ local events have been organized around the globe. …and the party favors are ready to pop. #dotNETConf is just 7 days away. Join in: https://t.co/rhYUbVsuAbpic.twitter.com/h3xaxrlNKB