Menu

Thursday 19 July 2018

Openssl Commands for Wildcard & SAN certificates.

OpenSSL is a general purpose cryptography library that provides an open source implementation of the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols.

   Required Software
  • ·         Openssl  rpm/software (Unix/Windows)
  • ·         Keytool  rpm/software (Unix/Windows)

Step 1: Create a configuration file (san.cnf) , consists certificates  details.

#########################################################

[ req ]
default_bits = 4096
prompt = no
encrypt_key = no
default_md = sha256
distinguished_name = dn
req_extensions = req_ext

[ dn ]
CN = *.MB.com
O = Advanced Travel Partners
OU = I.T.
L = Lowestoft
ST = Suffolk
C = GB

[ req_ext ]
subjectAltName = DNS: *.MB.com, DNS: MBox.com

#########################################################

where,
          default_bits         : means private key size.
          prompt                : means i will not ask for any input from user.
          encrypt_key        : means  private key will be unencrypted format.
          default_md          : means signature Algorithm (sha256RSA).

          subjectAltName   : means SAN dns. 

Screenshot:





Step 2: Generate a CSR & Private key using above configuration (san.cnf) file.

Command:
openssl  req   -new  -config san.cnf   -nodes   -keyout  MB.key   -out  MB.csr


Where,
          -config : created (san.cnf) configuration file location.
          -nodes  :  for no password prompt
          -keyout : output file name.

Screenshot:





Step 3: Now these CSR is to be share for CA certs.

You will receive thesecertificates:
  • .       Server certificate.
  • .       Intermediate certificate. 
  • .       Root Certificate.

**I have received ca-bundle & server certificate.

Where,
ca-bundle           : Contains (Root + Intermediate).
Server certificate: Is also called as main certificate or personal certificate.


**If you were using on Apache server:
Location:  $APACHE_HOME\conf\extra
File Name: httpd-ssl.conf

Below Changes done :
SSLCertificateFile   "C:\Apache2.4.33_Final\conf\ MB_com.crt "
SSLCertificateKeyFile   "C:\Apache2.4.33_Final\conf\ MB.key "
SSLCertificateChainFile   "C:\Apache2.4.33_Final\conf\MB_com.ca-bundle "


  

Step 4: Import or export  All the certificates in  .p12 format.

Command:
NOTE: Please provide new PASSWORD for a p12 file for future uses.

openssl pkcs12  -export  -chain  -CAfile  MB_com.ca-bundle   -inkey  MB.key   -in MB_com.crt  -out  MB.p12   -name  Cert_MB.com

where,
         -chain & -CA file : Ca- bundle certificate location.
         -inkey                   : key file location
         -in                         : server certificate location.
         -out                       : output  file name.
         -name                    : alias for server certificates.

Screenshot:




Step 5: Convert .p12 to JKS (keystore) format.

Command:
NOTE: Only, Add the server certificate and private key from the .p12 file to  JKS keystore.
Use same password used for p12 file.

keytool   -importkeystore    -srckeystore  MB.p12   -srcstoretype pkcs12   -destkeystore MB.jks  -deststoretype jks

Where,
          Keytool                : java utility.
         -importkeystore    : import key store file.
         -Srckeystore         : source key store file.
         -Srcstoretype        : source file type .
         -destkeystore        : output file  name.
         -deststoretype       : output file type.  


Screenshot:





Step 6: Convert JKS  to  .p12  (keystore) format.

Command:
NOTE: Only, Add the server certificate and private key from the .p12 file to  JKS keystore.
Use same password used for p12 file.

keytool   -importkeystore    -srckeystore  MB.jks    -destkeystore   MB.p12     -deststoretype pkcs12

Where,
          Keytool                : java utility.
         -importkeystore    : import key store file.
         -Srckeystore         : source key store file.
         -Srcstoretype        : source file type .
         -destkeystore        : output file  name.
         -deststoretype       : output file type.  





Step 7: Import a root or intermediate CA certificate to an existing (JKS).

Command:
keytool  -import  -trustcacerts  -alias  root_inter   -file   MB_com.ca-bundle   -keystore   MB.jks

Where,
           -trustcacerts  : ca-bundle or intermediate file location.
           -alias             : name for certificate.


Screenshot:




Step 8: Export Private key (.pem) format from .p12  format file.

Command:
openssl  pkcs12   -nocerts   -nodes  -in   MB.p12    -out    MB.key

Where,
          -nocerts : means only private key will be exported from file.


Screenshot:




Step 9: Export Certificates (.pem) format  from .p12  format file.

Command:
openssl  pkcs12   -nokeys    -nodes  -in   MB.p12    -out MB.pem

Where,

          -nokeys: : means only certificates will be exported from file.


Screenshot:



Step 10: Check an MD5 hash of the public key to ensure that it matches with what is in a CSR or private key


Commands:
  • openssl req -noout -modulus -in MB.csr | openssl md5
  •  openssl rsa -noout -modulus -in MB.key | openssl md5
  • openssl x509 -noout -modulus -in  MB_com.crt | openssl md5


Screenshot:





Reference link:-
https://www.sslshopper.com/article-most-common-openssl-commands.html
https://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html

Thanks :-)




Monday 9 July 2018

WebSphere App Server - Updating ports in existing profiles


Step 1: Make sure your profile "Servers" and "Nodeagent" is stopped.


Step 2: Remove the federated node from the "dmgr" (deployment manager ) console.
                Command:  ./removeNode.sh

Step 3: Create a two files on /temp directive,
               
  •  appserver.props
  •  portdefs.AppSrv02.props

Where,
           appserver.props contains profiles details.
           portdefs.AppSrv02.props contains the new ports, which needs to be update.


Step 4: Take backup of existing “portdef.props” file OR backup entire profile.


Step 5: Edit file “portdefs.AppSrv02.props” and paste the existing “portdef.props with updated  ports properties

Screenshot: previous ports $WAS_HOME/profiles/AppSrv02/properties/"portdef.props"





Screenshot: updated ports on new file "portdefs.AppSrv02.props".






Step 6: Edit file "appserver.props", provide the existing profile details & "location of  new ports file".

Screenshot: "appserver.props"





Step 7: Navigate to $WAS_HOME/bin & use below command.

./ws_ant.sh  -propertyfile  /tmp/was_props/appserver.props 
-file  /IBMWAS/IBM/profileTemplates/default/actions/updatePorts.ant

Where,
           ./ws_ant.sh is for WebSphere ant script.
           - propertyfile is a location of newly  created appserver.props  file.
            -file is a location for the existing type of profiles you were using.



  Screenshot : Command




  Screenshot : Updated ports on $WAS_HOME/profiles/AppSrv02/properties/"portdef.props"




Now you have updated the new ports successfully.









Saturday 7 July 2018

Apache error : Server ran out of threads to serve requests (Windows)


File name : error.log

***********************************************************************
[Wed Jul 04 13:47:24.134888 2018] [mpm_winnt:error] [pid 7676:tid 2184] AH00326: Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting
****************************************************************************

Description: This above error indicates, requests from users are not getting any thread to process further.


Solution: we have to increase a worker threads on “httpd-mpm.conf” file.

#######################################
<IfModule mpm_winnt_module>
                ThreadLimit         600
                ThreadsPerChild     600
                MaxRequestsPerChild 0
</IfModule>
#######################################

  
Means,1 parent process, exactly 1 child process with many threads, threads handle requests.

The MaxClients is optimal at 200 * the count of CPU cores for the prefork mpm  &  300 * the count of CPU cores for the workermpm.





NOTE :-
If you were not using this “httpd-mpm.conf “file on apache server.
By, default it will start with its, 64 worker threads.

***********************************************************************
mpm_winnt:notice] [pid 8296:tid 372] AH00354: Child: Starting 64 worker threads.
***********************************************************************
Thanks :