Download a sites certificates with openssl

The following snippet can be used to download all the CA certificates from a site, into seperate .crt files. The file name will be the last CN part from the issued information.

openssl s_client -connect $SITE:443 -showcerts \
        </dev/null 2>/dev/null | \
	awk '/^ [0-9] s:/,/^[-]+END CERTIFICATE/' | \
	csplit -q -z -f cert - '/^ [0-9] s:/' '{*}'
for file in cert*; do \
	name="$(awk -F= '/^ [0-9] s:/ {gsub(/[^A-Za-z0-9.]/, "", $NF); print $NF".crt"}' "${file}")"; \
	awk '/^[-]+BEGIN CERTIFICATE/,/^[-]+END CERTIFICATE/' "${file}" > "${name}"; \
	rm "${file}"; \
done

Example, if running the above with SITE=blog.mgor.net:

↳ openssl s_client -connect $SITE:443 -showcerts         </dev/null 2>/dev/null | awk '/^ [0-9] s:/'
 0 s:/CN=blog.mgor.net
 1 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3

Two certificate files will be created:

↳ ls *.crt
blog.mgor.net.crt  LetsEncryptAuthorityX3.crt

Thunderbird and Office365 (mail + calendar)

Here’s how you setup Thunderbird to work with mail and calendar from Office365.

Install dependencies

sudo apt install thunderbird

Start Thunderbird, and go to Tools, Add-ons, Get Add-ons.

Search for Lightning and install the add-on.

Goto Ericssons github repository for exchange calendar and download the latest stable version. Go back to Tools, Add-ons, Get Add-ons, click on the gear icon next to the search and choose Install Add-on From File.... Navigate to where you saved the xpi plugin file.

Configure mail

Go to Edit, Account Settings, Account Actions and Add Mail Account. Enter your settings.
IMAP server: outlook.office365.com:993
SMTP server: outlook.office365.com:587

Configure calendar

Go to the Calendar (lightning) tab, right click in the left menu pane under Calendar, chose New Calendar... and select On The Network.

Format: Microsoft Exchange 2007/2010/2013
Name: <Name of the calendar>
E-Mail: <E-mail account created in previous step>
Exchange Type: Microsoft Office365

Click Check server and mailbox, it will ask you for your password.

Folder base: Calendar folder

Finish the wizard, and you’re all done!

Skype for business (Office365) with pidgin-sipe

By using the pidgin-sipe plugin for pidgin, it is possible to connect to Office365, Skype for business.

First off, add the sipe-collab PPA and install the two main packages:

sudo apt-add-repository ppa:sipe-collab
sudo apt update
sudo apt install pidgin pidgin-sipe

Start pidgin and add a new account.

Tab Basic:
Protocol: Office Communicator
Username: <E-mail address>
Login: <E-mail address>
Password: <Password>
Remember password: <Checked>
Local alias: <Your name>

Tab Advanced (anything not mentioned should be left with default value):
Connection type: Auto
User Agent: UCCAPI/15.0.4420.1017 OC/15.0.4420.1017
Authentication scheme: TLS-DSK

Credit goes to frytek on ubuntuforums.org. sipe-collab source-code can be found on github from tieto.

WiFi problems after waking up from sleep, Ubuntu 16.10

After installing Ubuntu 16.10 I occasionally had problems with WiFi after waking up from sleep.

But of course there’s a workaround (credit to Joakim Koed on askubuntu.com and the solution).

sudo bash -c 'cat >/etc/systemd/system/wake-up.service <<EOF
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target
EOF'
sudo systemctl enable wake-up.service