Friday, May 31, 2019

PFX to PEM for Linux Azure CLI

In order to use a service principal for the Azure CLI on Linux via a certificate instead of password, the file must be a "certificate" (not private key or public key). Given a .PFX file, to convert it to the proper certificate file use:

openssl pkcs12 -in $CertName.pfx -clcerts -nodes -out $CertName.pem


If you try to feed it something else you're likely to get the very unhelpful error:

Traceback (most recent call last):
  File "/usr/lib64/az/lib/python2.7/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 560, in execute
    raise ex
Error: [('PEM routines', 'get_name', 'no start line')]


Monday, February 4, 2019

No GCM Push on Wifi

I ran into a problem where one day I noticed that I was no longer receiving GCM push notifications when on wifi on my Android Nexus 5x.  If I disabled wifi and used cellular data, notifications would work fine.  Using the dial code *#*#426#*#* I was able to locate the Google Play Services log console and I saw a bunch of messages like this:

02-04 08:32:35.939 net=1: Failed connection err:24
02-04 08:33:31.329 net=1: Failed connection err:24
02-04 08:33:31.595 net=1: Failed connection err:19
02-04 08:34:22.032 net=1: Failed connection err:24

I thought the problem was my phone but it turns out it was actually my DNS settings for my local network.  After a lot of painstaking work, I found that mtalk.google.com was resolving to 216.239.38.120.  This was because I was using DNS to force Google searches into "safe search" mode.  After adding a DNS entry for mtalk.google.com as 108.177.98.188, all of the sudden my GCM notifications started working again.  Yeah!