X

Blogs about Deep Learning, Machine Learning, AI, NLP, Security, Oracle Traffic Director,Oracle iPlanet WebServer

  • September 19, 2007

Using built-in hardware crypto accelerators of SPARC Enterprise T5120 server (powered by UltraSPPARC T2 i.e. Niagara2 processor) in Oracle iPlanet Web Server 7.0


Using built-in hardware crypto accelerators of SPARC Enterprise T5120 server (powered by UltraSPARC T2 i.e. Nigara2 processor) in Oracle iPlanet Web Server 7.0 update 9


In my previous
blog
I talked about SCF framework and Sun Java System Web Server
7.0 in general. This time I tried to make use of built-in hardware
crypto accelerators of SPARC Enterprise T5120 server (powered by Ultra SPARC-T2 i.e. Niagara 2 processor) in Oracle iPlanet Web Server 7.0 update 9.

T5120 server has intergrated onboard cryptographic acceleration supporting 10 embedded security industry-standard ciphers including DES, 3DES, AES, RC4, SHA1, SHA256, MD5, RSA to 2048 key, ECC, and CRC32.

Here is what I did :


Step 1 : Go to Webserver installation directory and start admin
server

# ./admin-server/bin/startserv


Step 2.1 : Go to Web Server 7.0 instance's config
directory and perform these manual steps

# cd https-foo.com/config/


2.2) First move the existing database to another directory

# mv /.sunw ./sunw.old

Setpin

# pktool setpin
Create new passphrase: type-password-here
Re-enter new passphrase: type-password-here
Passphrase changed.



2.3) List the current PKCS#11modules

# ../../bin/modutil
-list -dbdir .


Listing of PKCS #11 Modules
-----------------------------------------------------------
  1. NSS Internal PKCS
#11 Module

        
slots: 2 slots attached

       
status: loaded


        
slot: NSS Internal Cryptographic Services

       
token: NSS Generic Crypto Services


        
slot: NSS User Private Key and Certificate Services

       
token: NSS Certificate DB


  2. Root Certs
       
library name: libnssckbi.so

        
slots: 1 slot attached

       
status: loaded


        
slot:
NSS Builtin Objects
       
token: Builtin Object Token

-----------------------------------------------------------

2.4) Add SCF module

# ../../bin/modutil 
-dbdir . -add "Solaris Crypto Framework"
-libfile /usr/lib/libpkcs11.so -mechanisms RSA


...

Module "Solaris Crypto
Framework" added to database.


2.5) Enable SCF module

# ../../bin/modutil -enable
"Solaris Crypto Framework" -dbdir .

...

Slot "Sun Metaslot" enabled.
Slot "n2cp/0 Crypto Accel Bulk 1.0" enabled.
Slot "ncp/0 Crypto Accel Asym
1.0" enabled.

Slot "n2rng/0 SUNW_N2_Random_Number_Generator" enabled.



2.6) List modules to make sure add and enable stuff above succeeded.

# ../../bin/modutil 
-list -dbdir .


Listing of PKCS #11 Modules
-----------------------------------------------------------
  1. NSS Internal PKCS
#11 Module

        
slots: 2 slots attached

       
status: loaded


        
slot: NSS Internal Cryptographic Services

       
token: NSS Generic Crypto Services


        
slot: NSS User Private Key and Certificate Services

       
token: NSS Certificate DB


2. Solaris Crypto Framework
        library name: /usr/lib/libpkcs11.so
         slots: 4 slots attached
        status: loaded

         slot: Sun Metaslot
        token: Sun Metaslot

         slot: n2cp/0 Crypto Accel Bulk 1.0
        token: n2cp/0 Crypto Accel Bulk 1.0

         slot: ncp/0 Crypto Accel Asym 1.0
        token: ncp/0 Crypto Accel Asym 1.0

         slot: n2rng/0 SUNW_N2_Random_Number_Generator
        token: n2rng/0 SUNW_N2_RNG

  3. Root Certs
        library name: libnssckbi.so
         slots: 1 slot attached
        status: loaded

         slot: NSS Builtin Objects
        token: Builtin Object Token
-----------------------------------------------------------

2.7) List cryptoadm providers and their mechanisms:

# cryptoadm list -p

User-level providers:
=====================
/usr/lib/security/$ISA/pkcs11_kernel.so: all mechanisms are enabled. random is enabled.
/usr/lib/security/$ISA/pkcs11_softtoken_extra.so: all mechanisms are enabled. random is enabled.

Kernel software providers:
==========================
des: all mechanisms are enabled.
aes256: all mechanisms are enabled.
arcfour2048: all mechanisms are enabled.
blowfish448: all mechanisms are enabled.
sha1: all mechanisms are enabled.
sha2: all mechanisms are enabled.
md5: all mechanisms are enabled.
rsa: all mechanisms are enabled.
swrand: random is enabled.

Kernel hardware providers:
==========================
n2cp/0: all mechanisms are enabled.
ncp/0: all mechanisms are enabled.
n2rng/0: all mechanisms are enabled. random is enabled.


2.9) Disable the following mechanisms in User Level Providers

cryptoadm
disable 
provider=/usr/lib/security/\\$ISA/pkcs11_softtoken_extra.so \\  

             mechanism=CKM_SSL3_PRE_MASTER_KEY_GEN,CKM_SSL3_MASTER_KEY_DERIVE,CKM_SSL3_KEY_AND_MAC_DERIVE,\\
                       CKM_SSL3_MASTER_KEY_DERIVE_DH,CKM_SSL3_MD5_MAC,CKM_SSL3_SHA1_MAC

2.10) List to make sure these were disabled

# cryptoadm list -p
User-level providers:
=====================
/usr/lib/security/$ISA/pkcs11_kernel.so: all mechanisms are enabled. random is enabled.
/usr/lib/security/$ISA/pkcs11_softtoken_extra.so: all mechanisms are enabled, except CKM_SSL3_SHA1_MAC,CKM_SSL3_MD5_MAC,CKM_SSL3_MASTER_KEY_DERIVE_DH,CKM_SSL3_KEY_AND_MAC_DERIVE,
CKM_SSL3_MASTER_KEY_DERIVE,CKM_SSL3_PRE_MASTER_KEY_GEN. random is enabled.

Kernel software providers:
==========================
des: all mechanisms are enabled.
aes256: all mechanisms are enabled.
arcfour2048: all mechanisms are enabled.
blowfish448: all mechanisms are enabled.
sha1: all mechanisms are enabled.
sha2: all mechanisms are enabled.
md5: all mechanisms are enabled.
rsa: all mechanisms are enabled.
swrand: random is enabled.

Kernel hardware providers:
==========================
n2cp/0: all mechanisms are enabled.
ncp/0: all mechanisms are enabled.
n2rng/0: all mechanisms are enabled. random is enabled.
2.11) a) Now run the following Web Server CLI commands

# ../../bin/wadm --user=admin
Please enter
admin-user-password>
type-admin-server-password-here

wadm> list-configs
foo
wadm> pull-config
--config=foo foo
CLI201 Command 'pull-config' ran
successfully

wadm> list-tokens
--config=foo

internal
Sun
Metaslot

wadm>  create-selfsigned-cert --config=foo
--server-name=foo --nickname=Server-Cert --token="Sun Metaslot"

Please enter token-pin> type-password-here
CLI201 Command
'create-selfsigned-cert' ran successfully

wadm> list-http-listeners 
--config=foo

http-listener-1
wadm> set-ssl-prop --config=foo
--http-listener=http-listener-1
server-cert-nickname="Sun
Metaslot:Server-Cert" enabled=true

CLI201 Command 'set-ssl-prop'
ran successfully

wadm>  deploy-config foo
CLI201 Command 'deploy-config'
ran successfully

wadm>

\*\*

2.11) b) If you are using older version of Web Server and you do not have Admin CLI, you can use the following command to create the self signed certificate
# ../../bin/certutil -S -x -n "Server-Cert" -t "u,u,u" -s "CN=foo" -d . -h "Sun Metaslot"
Enter Password or Pin for "Sun Metaslot":
type-password-here

...

Continue typing until the progress meter is full:


|\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*|


Finished. Press enter to continue:

     Generating key. This may take a few moments...
    
#


2.11) c) OR you can create a self-signed certificate in NSS DB and export it and import it into Sun Metaslot :
# ../../bin/certutil -S -x -n "Server-Cert" -t "u,u,u" -s "CN=foo" -d .
Enter Password or Pin for "Sun Metaslot":
type-password-here


...


Continue typing until the progress meter is full:



|\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*|




Finished. Press enter to continue:



Generating key. This may take a few moments...
#

# ../../bin/pk12util  -o key-cert-data.pk12 -n "Server-Cert" -d .
Enter password for PKCS12 file: type-a-new-password-here-or-press-enter
Re-enter password: type-a-new-password-here-or-press-enter
pk12util: PKCS12 EXPORT SUCCESSFUL

# ../../bin/pk12util -i key-cert-data.pk12 -d . -h "Sun Metaslot"
Enter Password or Pin for "Sun Metaslot": type-password-here
Enter password for PKCS12 file: type-the-new-password-here
pk12util: PKCS12 IMPORT SUCCESSFUL

2.12) Now manually double check if the certificate exists
# ../../bin/certutil -L -d . -h "Sun
Metaslot"


Certificate Nickname                Trust Attributes


                                   SSL,S/MIME,JAR/XPI

Enter Password or Pin for "Sun
Metaslot":
type-password-here
Sun
Metaslot:Server-Cert                      u,u,u


Check that server.xml contains server-cert-nickname element
 <http-listener>
   
<name>http-listener-1</name>

   
<port>80</port>

   
<server-name>foo</server-name>

   
<default-virtual-server-name>foo</default-virtual-server-name>

   
<ssl>

     
<server-cert-nickname>Sun
Metaslot:Server-Cert</server-cert-nickname>

   
</ssl>

  </http-listener>

2.13) Start the server
#../bin/startserv
Oracle iPlanet Web Server 7.0.9 B07/04/2010 02:15
Please enter the PIN for the
"Sun Metaslot" token:
type-password-here
info: CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.6.0_20] from [Sun Microsystems Inc.]
info: HTTP3072:
http-listener-1:
https://foo:80
ready to accept requests

info: CORE3274: successful
server startup


2.14) Check the statistics using kstat

# kstat -n ncp0 | grep rsa

        rsagenerate                     6

        rsaprivate                      18

        rsapublic                       15


Send a request through the browser (with a cipher containing RSA) to this server https://foo:80/test.html, it should show test.html
I used tstclnt (a client bundled with NSS) to send request to the server using cipher c i.e. SSL3 RSA WITH RC4 128 MD5.

# tstclnt -h accel -p 81 -d . -n Server-Cert  -T -f -o -v  -c c < req.txt
tstclnt: connecting to accel:81 (address=10.133.169.154)
...

      tstclnt: SSL version 3.0 using 128-bit RC4 with 128-bit MD5 MAC
      tstclnt: Server Auth: 1024-bit RSA, Key Exchange: 1024-bit RSA
      ...
      HTTP/1.1 200 OK
      Server: Oracle-iPlanet-Web-Server/7.0
      Content-type: text/html
      Last-modified: Mon, 10 Jan 2011 09:45:03 GMT
      Etag: "12-4d2ad51f"
      Accept-ranges: bytes
      Content-length: 18
      Date: Mon, 10 Jan 2011 09:45:23 GMT
      Connection: close

      This is test.html
      ...

Now run kstat again,  if it shows an increase that means we are ok.

kstat -n ncp0 | grep -i rsa 

    rsagenerate                     6 
    rsaprivate                      18

    rsapublic                       16


Note : If

1. Web server does not present the Intermediate CA certificates
installed as Server Certificate Chain to the browser and that causes the
certificate validation by the browser to fail.
or
2. Client authentication fails with the following error message in the
errors log .  Root CA cert has been installed to the certificate database.

failure (16670): HTTP3068: Error receiving
request from 123.45.67.897(SEC_ERROR_UNKNOWN_ISSUER: Peer's
certificate is signed by an unknown issuer)

These two issues are caused by the
/.sunw directory not being accessible by the web server running user
"webservd". That directory has permissions 0700 and is owned by root.
Web Server starts up as root and then changes (using setuid) to user
"webservd".  Solution to this is
1) Have the web server running as root

2) Open up the permission on /.sunw so that it is readable by the web
server running user
3) Set  the environment variable SOFTTOKEN_DIR to point to some
directory that is owned by webservd before the web server is started.
The SCF will then access the files in $SOFTTOKEN_DIR/pkcs11_softoken/
during execution.

References


\*\*If you get an error in list-configs command like : "CLI104 Unable to communicate with the administration server: No such file or directory" then you are probably seeing bug "6606384 SCF consumers crash after mechanisms are disabled using cryptoadm when using libumem". Upgrade to Solaris 10 update 9 or apply patches. core dump should look like

# mdb ../../admin-server/config/core.18103

>::stack

libc.so.1`_lwp_kill+8(6, 0, 20f04, ff34ba3c, ff36a000, ff36abdc)

libumem.so.1`umem_do_abort+0x1c(44, e4ced4e8, 6, 20e40, ff356ad8, 0)

libumem.so.1`umem_err_recoverable+0x7c(ff357b54, a, 20d38, 0, ff36d0e8, ff357b5f)

libumem.so.1`process_free+0x114(12d3ee8, 1, 0, 3e3a1000, 1ec08, ff)

libpkcs11.so.1`pkcs11_slottable_delete+0x158(12d3ee8, a11628, a11628, f97c6bb0, 1, 1)

libpkcs11.so.1`pkcs11_fini+0x4c(f97c6b8c, 1, f97ae1c8, f97c6000, 17aac, f97c6b84)

libc.so.1`_postfork_child_handler+0x30(1d18, fd543800, 1c00, 4, fba5ca00, fd543800)

libc.so.1`fork+0x144(0, 2, 0, 3c, fd543800, fba5ca00)

libns-httpd40.so`CHILDEXEC_ERR ChildExec::_startListener()+0x19c(...)

libns-httpd40.so`CHILDEXEC_ERR ChildExec::PerformListenerOp(ListenerOp,int&)+0x14(...)

libns-httpd40.so`CHILDEXEC_ERR ChildExec::StartListener(int&)+0x48(...)

libns-httpd40.so`CHILDEXEC_ERR ChildExec::initialize(int&)+0xa8(...)

libns-httpd40.so`PRStatus cgistub_child_exec_init()+0x2d0(...)

libns-httpd40.so`PRStatus cgistub_init()+0x58(...)

...

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.