643 words
https://raindrop.io/collection/9927677 @_iwate

StreamWriter.WriteLine write LF line break code on Linux

I face to misterius issue.

OData batch response of multipart/mixed can not be parsed on Linux. It's good on Windows.

I check OData source code. And I've found what I think is the cause.

OData batch response write the content using by RawValueWriter. And RawValueWriter use StreamWriter.


StreamWrite use Environment.NewLineConst.

Environment.NewLineConst is LF on Unix

You know HTTP multipart content is need CRLF. If you create http writer, you should not use what is dependent on the environment like as StreamWriter.

Ascertia's code sign certigicate is cheep but...

Ascertia (https://account.ascertia.com/OnlineCA/default) sell certificate and user can test free certificate(30days).

It seems Messiah for me. but I realized import notes.

Note Ascertia Root Certificate Authority is not embedded within Windows or the common browsers but can be downloaded from here and easily added.

Ascertia Root Certificate Authority is not embedded within Windows!
Ascertia Root Certificate Authority is not embedded within Windows!
Ascertia Root Certificate Authority is not embedded within Windows!

oh no...

Microsoft Authenticode

I realized something shocking today.
I thought I'd turn off the WindowsInstaller warning for the Electron App I'm working on, but it looks like I need a Code Sign certificate for Microsoft Authenticode.

I tried to prepare it somehow, but there are few places that will sell it to individuals first. And so expensive 😭

I Contract PO Box

I've contracted post office box https://epost-tokyo.com/ today.

I am preparing my side business recently and I need new address for Notation based on the Specified Commercial Transaction Act.(in Japanese 特定商取引法に基づく表記)

The cost is 19,000 JPY within tax. It is 1,600 JPY / mo. Ummmm, That's nothing to sneeze at for me.

And, I've got new phone number of VoIP because same reason as address. The cost is 330 JPY per month.

Totally, new cost for my side business is 1,900 JPY per month.

The unit price of my side business is 1.49 USD and I have to sell 13 licenses for turn a profit.

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.