Skip to content

Instantly share code, notes, and snippets.

View matthiasbalke's full-sized avatar

Matthias Balke matthiasbalke

  • Germany
View GitHub Profile
@matthiasbalke
matthiasbalke / test-client-certificates.sh
Last active June 2, 2021 08:16
Test connection using client certificate
# using p12 store
curl --cert-type p12 --cert client-cert.p12:<password> --cacert cacert-containing-intermediate-and-root.txt https://hostname:1234/secure
# using openssl files
curl --cert certificate.cer --key private.key --cacert cacert-containing-intermediate-and-root.txt https://hostname:1234/secure
@matthiasbalke
matthiasbalke / create-p12-keystore.sh
Created May 19, 2021 09:02
create Java PKCS#12 keystore
#!/bin/bash
# place server key in server.key
# place server certificate in server.crt
# place intermediate certificate in intermediate.crt
cat server.crt intermediate.crt > certificate.chain.crt
openssl pkcs12 -export -inkey server.key -in certificate.chain.crt -name my-server -out server.p12
@matthiasbalke
matthiasbalke / create-p12-truststore.sh
Last active May 19, 2021 09:01
create Java trust store
#!/bin/bash
# to add a trusted certificate to the trust store
# place the trusted certificate in trusted-certificate.crt
cat intermediate.crt > trusted-certificate.crt
# import the certificate into the existing or create a new pkcs12 container
keytool -import -alias intermediate -file trusted-certificate.crt -keystore trust-store.p12 -storetype PKCS12 -storepass password
@matthiasbalke
matthiasbalke / .bashrc
Created February 26, 2021 07:30
git remove local merged branches
# checks whether local branches are merged into target branch
#
# usage:
# merged_branches <remote/target-branch-name>
#
# examples:
# merged_branches # default is master
# merged_branches origin/master
# merged_branches origin/release/9.0
#
@matthiasbalke
matthiasbalke / add-ssh-key-non-interactive.sh
Created March 21, 2019 08:12
add ssh key non-interactive using expect
#!/usr/bin/expect -f
# https://unix.stackexchange.com/a/90869/91094
spawn ssh-add /home/user/.ssh/id_rsa
expect "Enter passphrase for /home/user/.ssh/id_rsa:"
send "passphrase\n";
expect "Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)"
interact
@matthiasbalke
matthiasbalke / pom.xml
Created March 13, 2019 16:39
maven profile for including jdeps
<profile>
<id>jdeps</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jdeps-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
@matthiasbalke
matthiasbalke / run-dind.cmd
Last active February 28, 2019 10:48
docker-in-docker on Windows
# taken from https://stackoverflow.com/a/47229180/520631
docker run -it --rm --privileged --name dockerindocker -v //var/run/docker.sock:/var/run/docker.sock docker
@matthiasbalke
matthiasbalke / generate.cmd
Created November 16, 2018 17:01
Generate big dummy files for testing
fsutil file createnew c:\users\steve\desktop\10gb.img 107374182
@matthiasbalke
matthiasbalke / tailRecent.sh
Created September 11, 2018 12:13
tail most up to date file in directory
#!/bin/bash
tail -F `ls -tr | grep logFilePrefix | tail -n 1`
@matthiasbalke
matthiasbalke / extract-git-path.sh
Created February 23, 2018 13:14
extract a specific path from git repository with history
#!/bin/bash
git clone https://example.com/repo
# change into repository dir
cd repo
git checkout --detach
# delete all local branches