Showing posts with label Weblogic 12C. Show all posts
Showing posts with label Weblogic 12C. Show all posts

Monday, April 10, 2017

Get the Admin account password in Weblogic Systems


Recently I had the entrust to get the admin account password of weblogic, so after a little bit searching in oracle documentation and web I used the following code:

The steps:

1.- Build script get_password.py

from weblogic.security.internal import *
from weblogic.security.internal.encryption import *
encryptionService = SerializedSystemIni.getEncryptionService(".")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)

# Take encrypt password from user
pwd = raw_input("Paste encrypted password ({AES}fk9EK...): ")

# Delete unnecessary escape characters
preppwd = pwd.replace("\\", "")

# Display password
print "Decrypted string is: " + clearOrEncryptService.decrypt(preppwd)

2.- Set the environmental variables

sh $DOMAIN_HOME/bin/setDomainEnv.sh | source $DOMAIN_HOME/bin/setDomainEnv.sh

3.- Get the username and password

grep username $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^username=\(.*\)/\1/"
|
grep password $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^password=\(.*\)/\1/"

4.- cd $DOMAIN_HOME/security

java weblogic.WLST get_password.py


bash-3.2$ java weblogic.WLST get_password.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Paste encrypted password ({AES}fk9EK...): (OR USERNAME)

Decrypted string is: admin


Voilá!

Resources:
https://blogs.oracle.com

Update:

If your environment doesn't recognize your wlst command do the following:

 sh /$ENV/fmw/product/111/soa_111/common/bin/wlst.sh get_password.py

You must be located in $DOMAIN_HOME/security.


Friday, October 14, 2016

Create keystores for Weblogic 12C


To create keys issue the following commands:

keytool -genkey -keyalg RSA -alias aliasdemo -keystore alias_identity.jks -dname "CN=CEN-BI-DS-ODI01, OU=alias_demo, O=alias_demo, L=Mexico, ST=Mexico, C=MX" -storepass passW0rd -validity 3600 -keysize 2048 -keypass passW0rd
keytool -selfcert -v -alias alias_demo -keypass passW0rd -keystore alias_demo_identity.jks -storepass passW0rd -storetype jks -validity 3600
keytool -export -v -alias alias_demo -file "alias_demo.gob.mx-rootCA.der" -keystore alias_demo_identity.jks -storepass passW0rd
keytool -import -v -trustcacerts -alias alias_demo -file "alias_demo.gob.mx-rootCA.der" -keystore alias_demo_trust.jks -storepass passW0rd

Steps to deploy them in weblogic server
  • Identity Keystore: "/opt/oracle/keystore/alias_identity.jks"
  • Trust Keystore: "/opt/oracle/keystore/alias_trust.jks"
  • Alias: cenace
  • Store Password: passW0rd
  • Key Password: passW0rd
  • Valid for: 3600 Days (Approx 10 Years)
  • In the WebLogic Server Administration Console, click on "Servers" in the "Domain Structure" tree.
  • Click on the managed server you wish to configure.
  • Click on the "Configuration > Keystores" tab and sub-tab.
  • If you are running on production mode, click the "Lock & Edit" Button.
  • Click the "Change" button next to the "Keystores" setting.
  • Select the "Custom Identity and Custom Trust" option and click the "Save" button.
  • Enter the identity details. For example.

    • Custom Identity Keystore: /home/oracle/keystore/alias_identity.jks
    • Custom Identity Keystore Type: JKS
    • Custom Identity Keystore Passphrase: passW0rd
    • Confirm Custom Identity Keystore Passphrase: passW0rd
  • Enter the trust information. For example.

    • Custom Identity Keystore: /home/oracle/keystore/alias_trust.jks
    • Custom Identity Keystore Type: JKS
    • Custom Identity Keystore Passphrase: passW0rd
    • Confirm Custom Identity Keystore Passphrase: passW0rd
  • Click the "Save" button.
  • Click the "SSL" tab.
  • Enter the identity details. For example.

    • Private Key Alias: aliasdemo
    • Private Key Passphrase: passW0rd
    • Confirm Private Key Passphrase: passW0rd
  • Click the "Save" button.
  • If you are running in production mode, click the "Activate Changes" button.
=)