326 words

Fetch And Store Public Certificate

I needed to check my signature in the app I was creating, but was wondering where to store the public key.

One of the ideas was to embed it in the binary, but I would like to be able to get the latest one because the update becomes difficult.
So I came up with a way to store it in the X509Store.

The implementation is as follows.

using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;

namespace ConsoleApp3
    class Program
        static void Main(string[] args)
            var cert = new Program().GetPublicCertAsync("blog.iwate.me").Result;
            var rsa = cert.GetRSAPublicKey();
        public async Task<X509Certificate2> GetPublicCertAsync(string domain)
            var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);


            var collection = store.Certificates.Find(X509FindType.FindBySubjectName, domain, true);

            if (collection.Count > 0)
                return collection[0];

            X509Certificate2 certificate = null;
            await new HttpClient(new HttpClientHandler
                UseDefaultCredentials = true,
                ServerCertificateCustomValidationCallback = (sender, cert, chain, error) =>
                    if (error != SslPolicyErrors.None || !cert.Verify())
                        return false;

                    certificate = cert;
                    return true;
            }).SendAsync(new HttpRequestMessage(HttpMethod.Head, $"https://{domain}/"));

            return certificate;

Azure WebApps with File Shares

I need static web site hositng.
But Azure storage static website hositng feaure is not appropriate.
Because it cannot use any autentication.

Therefore, I use WebApps.
However, I do not want to use SFTP. or git deploy.

I remembered Azure function use storage file shares.
It is enabled by webapps config.

I add following two configs and restart webapp and it is so good.

CONTENTSHARE <file share name>

Azure Pricing

I'm making hoby services and considering Azure for hostring service.
However I don’t have much money.
I want to manage as cheap as possible.

Therefore, I research pricings and consider most cheap arcitecure.

Shared: Β₯1,250.928/month (limit 240 CPU min / day) 😒
Basic1: Β₯7,235.760/month πŸ€‘

Basic1: Β₯1,553.44/month πŸ˜—

Storage: ~Β₯100/month 😊
CDN : ~Β₯1,200/month πŸ™„
Function: ~Β₯0/month (within free plan) 😊

Container Instance
Instance: ~Β₯4000/month πŸ€‘
Registry: Β₯540/month πŸ€”

I think WebApps for Linux or Static WebSite with Function are better.

Hello, World!

This is my first blog.