IT Dribble

Mutterings, inconsistant tips, rants and randomness

Import private key and certificate into java keystore

by

How to import RSA private key into java keystore for tomcat
# You need:
# Your CA signed certificate (acme.com)
# Your private key (RSA)
# Your CA intermediate Certificate

# Import the certificates and key into a PKCS12 bundle

openssl pkcs12 -export -in certs/acme.com.crt -inkey acme.com.key -CAfile certs/DigiCertCA.crt  
-name "acme.com-2013-2014" -out acme.com.p12

(Remember the password you assigned it)

# Check if it worked:

openssl pkcs12 -in acme.com.p12  -info

# Import the PKCS12 bundle into a java keystore:

keytool -importkeystore -deststorepass YOUR-PASSWORD -destkeystore acme-keystore  -srckeystore acme.com.p12 
-srcstoretype PKCS12 -srcstorepass YOUR-PASSWORD 

Entry for alias acme.com-2013-2014 successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled

# Check your keystore:

keytool -list -keystore acme-keystore

Output should be similar to:

Enter keystore password:  YOUR-PASSWORD

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: acme.com-2013-2014
Creation date: Jan 3, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
-----BEGIN CERTIFICATE-----
keytool -list -keystore acme-keystore
Enter keystore password:  

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

acme.com.au-2013-2014, Jan 3, 2013, PrivateKeyEntry, 
Certificate fingerprint (SHA1): FA:A6:A3:42:95:34:15:68:26:35:40:18:8D:50:68:D4:15:C8:12:9E

# And match it against the import:

openssl x509 -fingerprint -in certs/acme.com.au.crt -noout
SHA1 Fingerprint=FA:A6:A3:42:95:34:15:68:26:35:40:18:8D:50:68:D4:15:C8:12:9E

Powershell command to check Send-As Permissions

by

Find all users who have Full Access to the mailbox of others:

Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | ? {($_.AccessRights -match "FullAccess") -and 
not ($_.User -like "NT AUTHORITYSELF")} | ft Identity, User

Finding all users who have Send-As :

Get-Mailbox -Resultsize Unlimited | Get-ADPermission | ? {($_.ExtendedRights -like "*send-as*") -and -not
($_.User -like "nt authorityself")} | ft Identity, User -auto

Finding all users who have Send-As (Restricted to an OU):

Get-Mailbox -Resultsize Unlimited | Get-ADPermission | ? {($_.ExtendedRights -like "*send-as*") -and
($_.Identity -like "*/SomeOU/Users/*") -and -not ($_.User -like "nt authorityself")} | ft Identity, User -auto

Find out who a particular user can Send-As:

Get-Mailbox -Resultsize Unlimited | Get-ADPermission | ? {($_.ExtendedRights -like "*send-as*") -and -not
($_.User -like "nt authorityself") -and ($_.User -like "DOMAINUsernameUwantToFind")} | ft Identity, User -auto

How to move flatpress to SSL

by

Apart from all the Virtual Hosting and SSL certificates, you have probably found that it keeps redirecting you to the HTTP version.
What you need to change is the defaults.php file.

Change:

define('BLOG_BASEURL', 'http://'.$_SERVER['HTTP_HOST']. BLOG_ROOT);

to:

define('BLOG_BASEURL', 'https://'.$_SERVER['HTTP_HOST']. BLOG_ROOT);

and that should do it!

Grant FullAccess to regular Active Directory user in Exchange 2010

by

In Exchange 2010 I needed to add a non mail-enabled user to use a shared mailbox. (Although technically it wasn’t a shared mailbox but a users mailbox in Exchange terminology) Add when I tried to grant the user Full Access Permissions I could only see Mail-Enabled users.

This required me to use the Powershell Command:

 Add-MailBoxPermission reception@localdomain.com -User:'CN=Full Name,OU=Users,OU=City,DC=localdomain,DC=com -AccessRights FullAccess 

What is interesting is that after performing the above, other non-mail enabled users could be added via the GUI afterwards….

Delete certain messages from Postfix Queue

by

Ever had some alerting software spam your production mail queue with 1000’s of alerts?
And you dont want to delete every message individually…

Here is the solution to delete all messages destined for user@example.com:

mailq | tail -n +2 | grep -v '^ *(' | 
gawk 'BEGIN {RS = ""} /user@example.com/ {print $1}' | 
tr -d '*!' | postsuper -d - 

Thanks to http://www.keithscode.com for that one!