listen my_cf
bind :80
mode http
reqadd X-Forwarded-Proto:\ https
http-request set-header Host dsomehost.cloudfront.net
server my_cf_pt dsomehost.cloudfront.net:443 ssl sni req.hdr(Host)

Few quick notes: the port can be anything you like, the connection must be made via HTTP; tcp won’t work due to the SNI requirement.

The important part here is feeding the SNI to cloudfront ala sni req.hdr(Host)

An extra thing you may wish to do, depends on your resolver setup. IP ranges are pretty broad and non-static for cloudfront so you can set the resolver to use resolver myresolvername at the end of the server line and setup your resolver…

originally posted at https://chrismckee.co.uk/c-logo-for-stuff-and-stickers/
around 07/2013

Back in early 2013 I was pasting stickers all over my Acer, as if it was some sort of third-rate thermal insulation, and I thought to myself, wouldn’t it be nice if I could have a C# one.

Annoyingly all the C# ones were god awful. But Jeremy Kratz had made a nice C++ one while at MSFT and had kindly made it clear he wasn’t bothered about the licence something confirmed recently.

Image for post
Image for post

Anyhoo I liked it and decided to try and replicate it in Illustrator then sort for print in PhotoShop, whacked in…

When copying to the local file system I always use the following rsync options:

rsync -aWhv --no-compress --progress /source/ /destinationfolder/

--no-compress as it's on the same machine
--progress speaks for itself

-a preserves ownership & permissions using archive flag
-W copying whole files only
# and optional ones for watching
-h human-readable transfer rate and file sizes
-v keeps it verbose so we can see whats happening

Things are rarely simple or obvious when working across languages; especially when one is .net.
Rather than waste time here’s the code, in its long form.

Test parameters

With a key 182634d8894831d5dbce3b3185c50881
and a message or data value of some random junk
with both solutions we should receive d94ed997943420b7d5dfb9b31ae236b7b5225510d8f0314c54ad44fb5fd44a06


public string HmacSHA256(string key, string data)
string hash;
ASCIIEncoding encoder = new ASCIIEncoding();
Byte[] code = encoder.GetBytes(key);
using (HMACSHA256 hmac = new HMACSHA256(code))
Byte[] hmBytes = hmac.ComputeHash(encoder.GetBytes(data));
hash = ToHexString(hmBytes);
return hash;

public static string ToHexString(byte[] array)
StringBuilder hex = new StringBuilder(array.Length * 2);
foreach (byte b in array)
hex.AppendFormat("{0:x2}", b);
return hex.ToString();

Which will generate the same value for the same given inputs as:

Python 2.7/3

hmac.new(key.encode('utf-8'), data.encode('utf-8'), hashlib.sha256).hexdigest()

Chris McKee

Engineer. (archived blog posts https://bit.ly/30qrna1)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store