Showing posts with label firefox. Show all posts
Showing posts with label firefox. Show all posts

Monday, January 04, 2010

Firefox private key/certificate import/export

Recently I am dealing with X.509 related stuff. The browser I am using is Firefox 3.5.3.

Generation and Import

The steps of generating and importing private key and certificate consist of:

  1. Public/private key pair generation
    You can use standalone utility (e.g. openssl) to generate them.
  2. Then you generate a self-signed certificate for the public key generated in the first step.
    Also, you can generate a Certificate Request message and send it to an external CA to apply for a certificate.
  3. Now you have both private key and the associated certificate.
  4. You need to put both of them into a single pkcs12 file which can be recognized by Firefox.
  5. Then you can import the pkcs12 file into Firefox by clicking
    Tools –> Options –> Advanced –> Encryption –> View Certificates –> Your Certificates –> Import…

If you use javascript, you can use crypto object to generate them.

  1. Use crypto.generateCRMFRequest to
    generate a key pair and create a Certificate Request message
  2. Send the generated Certificate Request message to remote server
    “The string found by accessing crmfObject.request is the base-64 encoded CRMF message to be sent to the CA/RA”
  3. After your certificate request is approved, you will get a public key certificate
  4. You can import the certificate into your browser.

Note: In this case, you don’t need to import the private key because it is imported automatically when function crypto.generateCRMFRequest is called.

Export

Export your private key and certificate from Firefox:

Tools –> Options –> Advanced –> Encryption –> View Certificates –> Your Certificates –> Backup…
Note: the keystore format supported is pkcs12.

Export trusted certificates from Firefox:

Tools –> Options –> Advanced –> Encryption –> View Certificates –> {corresponding tab} –>Export
Note: Firefox supports couple of different formats including PEM, PKCS#7, etc.

Friday, April 11, 2008

Fiddler in Firefox

The only reason that sometimes I use IE is Fiddler which is an excellent HTTP analytic and debugging tool. By searching around, I found that it could be used with Firefox besides IE. The official document is here http://www.fiddlertool.com/Fiddler/help/hookup.asp.

For Firefox 1.x, you need to select Tools -> Options -> General -> Connection Settings, then a pop-up windows is displayed. You select "Automatic proxy configuration URL" and input "C:\Documents and Settings\gerald\My Documents\Fiddler2\Scripts\BrowserPAC.js" in my case. You should modify the path accordingly. That file BrowserPAC.js is created and maintained by Fiddler which contains proxy information. Every time Fiddler is started or shutdown, that file is modified to reflect the state of Fiddler.

When Fiddler is started, the file is changed to:

function FindProxyForURL(url, host){
  return 'PROXY 127.0.0.1:8888';
}

From the content, you can guess that, actually Fiddler works as a proxy server which listens at port 8888. You can make any HTTP application which supports proxy setting redirect traffic to Fiddler.
Of course, you can set "Manual proxy configuration" for Firefox and type proxy address 127.0.0.1:8888. However, every time you want to  or don't want to use Fiddler, you must change the proxy setting. It is not convenient.

When Fiddler is shut down, the file is changed to:

function FindProxyForURL(url, host){
  return 'DIRECT';
}

That looks great, right? But there is a pitfall. Firefox does not detect change of the proxy configuration file. It means when you start or shut down Fiddler, Firefox will not be able to detect that. You must force Firefox to reload the proxy file:
 image