Decrypting 3DES in weblogic 8.1 configuration

Very useful tip, how to decrypt 3DES hashed password from configurations.

http://gustlik.wordpress.com/2008/08/06/decryption-of-configuration-passwords-in-weblogic/

You should add below code to class  from here:

http://geronimo.apache.org/apidocs/2.0.1/src-html/org/apache/geronimo/converter/bea/Weblogic81Utils.html

Below my version of main.
With some errors handlings

public static void main(String args[]) {
try{
if ( args== null || args.length<3 ) {
System.out.println("Usage:" );
System.out.println("arg1 = Server/lib or the Directory which has the requried JAR files");
System.out.println("arg2 = App Domain or the Directory which has SerializedSystemIni.dat");
System.out.println("arg3 = 3DES hashed password");
System.exit(0);
}
if  (! new File(args[0]).exists()) {
System.out.println("Path ["+args[0]+"] does not exists");
System.exit(0);
}
if  (! new File(args[1]).exists()) {
System.out.println("Path ["+args[1]+"] does not exists");
System.exit(0);
}
String beaDir = args[0];
String appDir = args[1];
String hashedPassword = args[2];
Weblogic81Utils weblogic81Utils = new Weblogic81Utils(beaDir, appDir);
String plainTextPassword = weblogic81Utils.decryptString(hashedPassword);
String configXML = weblogic81Utils.getConfigXML();
Properties bootProperties = (Properties) weblogic81Utils.getBootProperties();
System.out.println("---------------------------------------------------------------------");
System.out.println(hashedPassword + " == " + plainTextPassword);
System.out.println("boot.properties" + " <username> " + bootProperties.getProperty("username"));
System.out.println("boot.properties" + " <password> " + bootProperties.getProperty("password"));
System.out.println("---------------------------------------------------------------------");
}
catch (Exception e) {
    throw (RuntimeException)new IllegalArgumentException("Unable to initialize encryption routines from provided ar
guments").initCause(e);
}
} //end of main

Import private key and certificate into Java Key Store (JKS)

Receipt taken from

http://www.agentbob.info/agentbob/79-AB.html

This method describe how to

Import private key and certificate into Java Key Store (JKS).

firtst you have to convert key in  PEM format  to DER with openssl

openssl pkcs8 -topk8 -nocrypt -in key.pem -inform PEM -out key.der -outform DER
openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER

in next step you can kreate keystore with java class below.

user@host:~$ java ImportKey key.der cert.der
Using keystore-file : /home/user/keystore.ImportKey
One certificate, no chain.
Key and certificate stored.
Alias:importkey  Password:importkey

import java.security.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.security.spec.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.util.Collection;
import java.util.Iterator;

/**
* ImportKey.java
*
* <p>This class imports a key and a certificate into a keystore
* (<code>$home/keystore.ImportKey</code>). If the keystore is
* already present, it is simply deleted. Both the key and the
* certificate file must be in <code>DER</code>-format. The key must be
* encoded with <code>PKCS#8</code>-format. The certificate must be
* encoded in <code>X.509</code>-format.</p>
*
* <p>Key format:</p>
* <p><code>openssl pkcs8 -topk8 -nocrypt -in YOUR.KEY -out YOUR.KEY.der
* -outform der</code></p>
* <p>Format of the certificate:</p>
* <p><code>openssl x509 -in YOUR.CERT -out YOUR.CERT.der -outform
* der</code></p>
* <p>Import key and certificate:</p>
* <p><code>java comu.ImportKey YOUR.KEY.der YOUR.CERT.der</code></p><br />
*
* <p><em>Caution:</em> the old <code>keystore.ImportKey</code>-file is
* deleted and replaced with a keystore only containing <code>YOUR.KEY</code>
* and <code>YOUR.CERT</code>. The keystore and the key has no password;
* they can be set by the <code>keytool -keypasswd</code>-command for setting
* the key password, and the <code>keytool -storepasswd</code>-command to set
* the keystore password.
* <p>The key and the certificate is stored under the alias
* <code>importkey</code>; to change this, use <code>keytool -keyclone</code>.
*
* Created: Fri Apr 13 18:15:07 2001
* Updated: Fri Apr 19 11:03:00 2002
*
* @author Joachim Karrer, Jens Carlberg
* @version 1.1
**/
public class ImportKey  {

/**
* <p>Creates an InputStream from a file, and fills it with the complete
* file. Thus, available() on the returned InputStream will return the
* full number of bytes the file contains</p>
* @param fname The filename
* @return The filled InputStream
* @exception IOException, if the Streams couldn’t be created.
**/
private static InputStream fullStream ( String fname ) throws IOException {
FileInputStream fis = new FileInputStream(fname);
DataInputStream dis = new DataInputStream(fis);
byte[] bytes = new byte[dis.available()];
dis.readFully(bytes);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
return bais;
}

/**
* <p>Takes two file names for a key and the certificate for the key,
* and imports those into a keystore. Optionally it takes an alias
* for the key.
* <p>The first argument is the filename for the key. The key should be
* in PKCS8-format.
* <p>The second argument is the filename for the certificate for the key.
* <p>If a third argument is given it is used as the alias. If missing,
* the key is imported with the alias importkey
* <p>The name of the keystore file can be controlled by setting
* the keystore property (java -Dkeystore=mykeystore). If no name
* is given, the file is named <code>keystore.ImportKey</code>
* and placed in your home directory.
* @param args [0] Name of the key file, [1] Name of the certificate file
* [2] Alias for the key.
**/
public static void main ( String args[]) {

// change this if you want another password by default
String keypass = “importkey”;

// change this if you want another alias by default
String defaultalias = “importkey”;

// change this if you want another keystorefile by default
String keystorename = System.getProperty(“keystore”);

if (keystorename == null)
keystorename = System.getProperty(“user.home”)+
System.getProperty(“file.separator”)+
“keystore.ImportKey”; // especially this ;-)

// parsing command line input
String keyfile = “”;
String certfile = “”;
if (args.length < 2 || args.length>3) {
System.out.println(“Usage: java comu.ImportKey keyfile certfile [alias]“);
System.exit(0);
} else {
keyfile = args[0];
certfile = args[1];
if (args.length>2)
defaultalias = args[2];
}

try {
// initializing and clearing keystore
KeyStore ks = KeyStore.getInstance(“JKS”, “SUN”);
ks.load( null , keypass.toCharArray());
System.out.println(“Using keystore-file : “+keystorename);
ks.store(new FileOutputStream ( keystorename  ),
keypass.toCharArray());
ks.load(new FileInputStream ( keystorename ),
keypass.toCharArray());

// loading Key
InputStream fl = fullStream (keyfile);
byte[] key = new byte[fl.available()];
KeyFactory kf = KeyFactory.getInstance(“RSA”);
fl.read ( key, 0, fl.available() );
fl.close();
PKCS8EncodedKeySpec keysp = new PKCS8EncodedKeySpec ( key );
PrivateKey ff = kf.generatePrivate (keysp);

// loading CertificateChain
CertificateFactory cf = CertificateFactory.getInstance(“X.509″);
InputStream certstream = fullStream (certfile);

Collection c = cf.generateCertificates(certstream) ;
Certificate[] certs = new Certificate[c.toArray().length];

if (c.size() == 1) {
certstream = fullStream (certfile);
System.out.println(“One certificate, no chain.”);
Certificate cert = cf.generateCertificate(certstream) ;
certs[0] = cert;
} else {
System.out.println(“Certificate chain length: “+c.size());
certs = (Certificate[])c.toArray();
}

// storing keystore
ks.setKeyEntry(defaultalias, ff,
keypass.toCharArray(),
certs );
System.out.println (“Key and certificate stored.”);
System.out.println (“Alias:”+defaultalias+”  Password:”+keypass);
ks.store(new FileOutputStream ( keystorename ),
keypass.toCharArray());
} catch (Exception ex) {
ex.printStackTrace();
}
}

}// KeyStore

gatherting SSL private key from JKS keystore with java class

Working java class example from page:

http://stackoverflow.com/questions/150167/how-do-i-list-export-private-keys-from-a-keystore

import java.io.FileInputStream;
import java.security.Key;
import java.security.KeyStore;
import sun.misc.BASE64Encoder;

public class DumpPrivateKey {
     /**
     * Provides the missing functionality of keytool 
     * that Apache needs for SSLCertificateKeyFile.
     *
     * @param args  <ul>
     *              <li> [0] Keystore filename.
     *              <li> [1] Keystore password.
     *              <li> [2] alias
     *              </ul>
     */
    static public void main(String[] args)
    throws Exception {
        KeyStore ks = KeyStore.getInstance("jks");
        ks.load(new FileInputStream(args[0]), args[1].toCharArray());
        Key key = ks.getKey(args[2], args[1].toCharArray());
        String b64 = new BASE64Encoder().encode(key.getEncoded());
        System.out.println("-----BEGIN PRIVATE KEY-----");
        System.out.println(b64);
        System.out.println("-----END PRIVATE KEY-----");
    }
}

weblogic cluster multicast tets

java -cp ../../../server/lib/weblogic.jar utils.MulticastTest -P 7001 -A 239.192.0.0 -N srv1

-P port
-A multicast address
-N message send to other members

support patterns found:

https://support.bea.com/application_content/product_portlets/support_patterns/wls/MulticastErrorsPattern.html

How to browser Weblogic’s embeddedLDAP

first change EmbeddedLDAP password (i.e. weblogic) from console.

ldapsearch -x -w weblogic -D “cn=Admin” -b “dc=test” -h localhost -p 7001 uid=weblogic

where -w weblogic – EmbeddedLDAP administrator password

-x            – selects simple authentication method
-D “cn=Admin” – we are binding LDAP Administrator
-b dc=test    – where ‘test’ – domainname
-h localhost  – Weblogic’s listen address
-p 7001       – Welogic’s listen port
uid=weblogic  – search filter – here we are looking for weblogic entry

full ldap search:

ldapsearch -x -w weblogic -D “cn=Admin” -b “dc=test” -h localhost -p 7001 *

szyfrowanie hasla do 3DES w weblogic 8.1

java -cp weblogic.jar -Dweblogic.RootDirectory=katalog_gdzie_jest_SerializedSystemIni.dat weblogic.security.Encrypt Twoje_tajne_haslo

opis narzadu
http://e-docs.bea.com/wls/docs90/admin_ref/utils.html#1209592

deployment from commnad line in weblogic 7

Sometimes it could be a problem to deploy/redeploy application from command line.
Sequence that works for me.
1. Stop weblogic
2. Remove all .wlnotdelete (server folder, and application folder)
3. Remove old apploction entries from config.xml
4 .start weblogic
5. issue deployment command

java -Dweblogic.security.SSL.trustedCAKeyStore=truestedcerts.keystore -cp /license/bea:/weblogic/live/server/lib/weblogic.jar weblogic.Deployer -adminurl t3s://admin.server.org:8012 -debug -verbose -userconfigfile WebLogicConfig.properties -userkeyfile WebLogicKey.properties -name APPLICATIONNAME -source /path/to/application/APPLICATION.ear -activate

weblogic 7 application redeployment

java -Dweblogic.security.SSL.trustedCAKeyStore=TrustedKeysKeystore.keystore -cp /license/bea:/opt/weblogic/live/server/lib/weblogic.jar weblogic.Deployer -url t3s://myAdminServer.instance.org:7012 -userconfigfile WebLogicConfig.properties -userkeyfile WebLogicKey.properties -activate -name myApplicationName -source myApplicationEar.ear -targets myInstanceName

comparison 8.1 and 9.2 – shortcut

There shouldn’t be any additional cost on upgrading licenses it depends on Company agreement with BEA.

 

Additional cost is related to applications and operational environment adaptation to new version.

 

 

Benefits:

New versions of technologies are supported: J2EE 1.4 and JDK 1.5 and in 64-bit JVM.

All supported configurations on page:

 

 http://edocs.bea.com/wls/docs92/notes/new.html#wp1244325

 

Comparing to WLS 8.1 (J2EE 1.3 and JDK 1.4 on 32-bit JVM)

 

http://edocs.bea.com/wls/docs81/notes/new.html#1182609

 

New version of JDK gives you performance gain on the same hardware, and possibility to run on new types of hardware and OS.

Good example is multicore Sun Sparc T2000 (http://www.sun.com/servers/coolthreads/se_t2000/index.xml)

 

 

Some additional links:

 

 

Good comparison JVM performance comparison:

 

http://www.spec.org/osg/jbb2000/results/jbb2000.html

 

Some Application Servers Comparison

 

http://www.spec.org/jAppServer2004/results/jAppServer2004.html

 

 

Differences between 8 and 9 versions of weblogic

 

http://edocs.bea.com/wls/docs92/notes/new.html

http://edocs.bea.com/wls/docs90/notes/new.html

http://edocs.bea.com/wls/docs81/notes/new.html

weblogic 7 changing trusted CA Keystore

http://edocs.bea.com/wls/docs70/upgrade/upgrade6xto70.html

  1. Specify the following command-line argument for the client:

    -Dweblogic.security.SSL.trustedCAKeyStore=absoluteFilename

    where absoluteFilename is the name of the keystore that contains the trusted certificate authority

    It only one method to connect via t3s . Other method is to put trusted CA cert to default java CA cert

« Starsze wpisy