Category Archives: Uncategorized

Importing a SSL certificate into a Java Keystore via a PKCS12 file

Here are the instructions on how to import a SSL certificate into the Java Keystore from a PKCS12 (pfx or p12) file.

  1. Create a new keystore
    1. Navigate to C:\Program Files\Java\jdk_xxxx\bin\ via command prompt
  2. Execute: keytool -genkey -alias mycertificate -keyalg RSA -keysize 2048 -keystore mykeystore
    1. Use password of: Use the same password/passphrase as the PKCS12 file
    2. What is your first and last name?  (should be the dns you're going to use) [Unknown]:  server.mydomain.com
      What is the name of your organizational unit? [Unknown]: MyCompanysITDepartment
      What is the name of your organization?  [Unknown]:  MyCompany
      What is the name of your City or Locality?  [Unknown]:  CITY
      What is the name of your State or Province?  [Unknown]:  STATE
      What is the two-letter country code for this unit?  [Unknown]:  US
      Is CN=...................................... correct?  [no]:  yes
      Enter key password for <mycertificate>
      (RETURN if same as keystore password): Hit Return/Enter
  3. Empty the keystore
    1. Execute via command prompt: keytool -delete -alias mycertificate -keystore mykeystore
    2. Ensure nothing is in the keystore by executing: keytool -v -list -keystore mykeystore
  4. Import the PKCS12 File
    1. Execute via command prompt: keytool -v -importkeystore -srckeystore whateverthefileis.p12 -srcstoretype PKCS12 -destkeystore mykeystore -deststoretype JKS
    2. Enter the PKCS12 password/passphrase for both the Source and Destination password.

Attempt to configure DHCP server failed with error code 0x8007005. Access is denied.

Symptoms:

When trying to deploy DHCP on a member server (not a DC), you receive the following error:

Attempt to configure DHCP server failed with error code 0x8007005. Access is denied.

DHCP Error 0x8007005

When you go to Authorize the server you receive "Access Denied" as well.

Solution:

This is caused by permission issues on the user's account.  To fix this, first right click on IPv4 and then select Properties.  Click on the Advanced tab and then click on Credentials.  Inside of here, enter in the credentials you want to use as the service account to run DHCP.

DHCP Credentials

Next, open up Server Manager, expand Configuration, expand Local Users and Groups.  Click on DHCPAdministrators, and then add your service account.

DHCP Administrators group

Next, restart the DHCP Server service.  Inside of server manager, right click on the DHCP server and click Authorize.  Restart the service one last time, and each of your DHCP scopes should now be up (with green checkmarks).

 

 

Creating an installer for your application in Visual Studio 2012

In Visual Studio 2012, Microsoft removed the ability to make quick installers for your application. Now they recommend using a third party like Wix or InstallShield. This tutorial will go over using InstallSheild's free light version to make an installer for your application.

Please note, you cannot use InstallShield's product with the Express versions of Visual Studio.  If you use the express edition, you will not see the "Other Project Types" and "Setup and Deployment" folders mentioned later on.

First head over to InstallShield's website and register for the product.  It is free, but you have to register with a valid email address to receive a license key:

http://learn.flexerasoftware.com/content/IS-EVAL-InstallShield-Limited-Edition-Visual-Studio?lang=1033&ver=pro

Download and install the program.

Once installation is done, launch the program below as an Administrator:

C:\Program Files (x86)\InstallShield\2012SpringLE\System\TSConfig.exe

Enter your serial number from an auto-generated email they sent you when you downloaded InstallShield Limited and hit Activate.

InstallShield License

Next, open up Visual Studio 2012 (again, note we are not using express)

Click File->New Project.

New Project - Visual Studio

Expand Other Project Types and select Setup and Deployment.  Inside of there, you should see InstallShield Limited Edition Project (again, you won't see this in Visual Studio Express editions).  Click OK.

Other Project Types - InstallShield

At this point, you should see a guided GUI (Project Assistant) to create your installer.  Inside of the Solution Explorer, you will see additional items you can select to configure advanced options.

Project Assistant - InstallShield

How to validate numeric-integer input in C

I had one of my buddies ask me how to validate input in C today... Turns out the task is kind of daunting. I thought I could get away with the following below:

int status, input;
status = scanf("%d", &input);
while(status!=1){
	printf("Incorrect number... please try again: ");
	status = scanf("%d", &input);
}

but the problem is you receive an infinite loop. The reason behind this is when you hit return\enter on your keyboard, a newline character is passed in as input. These extra hidden characters are what is messing with your input and spawning the infinite while loop. Luckily, I was able to parse through the extra characters one-by-one and get something working.

Hopefully this helps someone else!

#include<stdio.h>
int main(void){
	// input	user input -- hopefully a number
	// temp		used to collect garbage characters
	// status	did the user enter a number?
	int input, temp, status;

	printf("Please enter a number: ");
	status = scanf("%d", &input);
	while(status!=1){
		while((temp=getchar()) != EOF && temp != '\n');
		printf("Invalid input... please enter a number: ");
		status = scanf("%d", &input);
	}

	printf("Your number is %d\n",input);
	return 0;
}

How to move a column in a table in mySQL

Execute the following query:
ALTER TABLE mytable MODIFY COLUMN columntobemoved INT AFTER columnbefore;

mytable = the table you are modifying
columntobemoved = the column that will move in the table
columnbefore = the column that will be before the column you move. I.e. if you have columns a, b, c and you want to put columntobemoved after b (so between b and c), you would use b as the columnbefore value

 

Managing Adobe Reader files with iTunes - on your iPad or iPod Touch

This tutorial assumes you already have iTunes setup, you are logged into it with your Apple account, and your iPad has been synchronized to your iTunes account.  Also, this guide assumes you are using an iPad, but I believe the steps are the same for an iPod touch as well.

  1. Open up iTunes
  2. Plug-in your iPad
  3. Press the Alt key, click on the View menu, and then select Show Sidebar
  4. Getting to the Adobe Reader app on your iPad
    1. Select your iPad
      1. Selecting your iPad
    2. Click on Apps in the top middle of the screen
      1. Selecting Apps
    3. Scroll down and click on the Adobe Reader app
      1. Adobe Reader App
  5. To add files to your iPad
    1. Click on the Add button
    2. Navigate to the folder you want, hold the control key, and select the files you want to send to your iPad (they must be in pdf format)
    3. Maps
    4. Click Open (note you cannot upload folders to your iPad)
  6. To backup files from your iPad to your computer
    1. Click on the folder you want and click on the Save To… button
    2. Navigate to the folder you want to place the folder in (iTunes will create the folder inside of the folder you are selecting).
    3. Select Folder
    4. Click the Select Folder button (you do not need to type in anything, just click the button)
      1. At this point, if you were to navigate to your folder, you should see the folder you selected in iTunes, and then inside of that folder, the folder you selected to backup.
        1. Note: iTunes doesn't copy files from the folder you selected, it copies the folder and sub-items in it to a new folder that you selected.
  7. To create folders on your iPad, do the following:
    1. Launch the Adobe Reader application
    2. Click on Documents on the left side
    3. Click the Edit button in the top right
    4. Click on the Folder icon with a + sign on it
    5. Type in the folder name and click Save
  8. To move PDFs into a folder, launch the Adobe Reader app on your iPad (NOTE: you cannot drag the files inside of iTunes into the folders)
    1. Click on Documents on the left side
    2. Click the Edit button in the top right
    3. Find your PDFs and click on the little Circle icon next to it
        1. When you do that, it should turn red with a check mark
    4. Click on the icon with a diagonal arrow on a folder
    5. Click Move selected documents
    6. Select the folder you want to move the PDFs to

How to install Python via command line on Linux

At the time of writing this, Python 2.7.3 is the latest build of the 2.7 builds. You can simply replace the wget url with the Python 3.x build you wish to download if you want to use those releases instead.

  1. Download the tarball
    1. wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
  2. Extract the contents
    1. tar -xzf Python-2.7.3.tgz
  3. Navigate to the extracted folder
    1. cd Python-2.7.3
  4. Configure/Install Python
    1. ./configure
    2. make
    3. sudo make install

Generating a PKCS12 file with openSSL

  1. Generate the CSR
    1. openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  2. Sign the CSR with your Certificate Authority
    1. Send the CSR (or text from the CSA) to VeriSign, GoDaddy, Digicert, internal CA, etc.
  3. Download the CRT
    1. Grab a copy of the signed certificate from your CA and place both the signed certificate and the CA chain certificate inside the same folder as your csr
  4. Create the PKCS#12 file (.pfx .p12)
    1. openssl pkcs12 -export -out nameofpkcsfilewearegoingtogenerate.pfx -inkey yourdomain.key -in publiccertfromCA.crt -certfile CAcertificatechain.crt
    2. Enter in a password that will be used to protect your PKCS file's private key

That's all that's to it!

Note: If you have multiple certificate authorities, you will have to create a certificate chain.  Use the following command for Step 4:

openssl.exe pkcs12 -export -in publiccertfromCA.crt -inkey yourdomain.key -name “MyCertYouCanChangeThisToWhateverItsAnAliasFriendlyName” -chain -CAfile certs.pem -passout pass:testpassword -out nameofpkcsfilewearegoingtogenerate.pfx

The certs.pem file will contain a list of your certificate authorities, starting from your intermediate authorities to the root authorities.

—–BEGIN CERTIFICATE—–
INTERMEDIATECERTIFICATEBASE64STUFFHERE.crt
—–END CERTIFICATE—–
—–BEGIN CERTIFICATE—–
ROOTCERTIFICATEBASE64STUFFHERE.crt
—–END CERTIFICATE—–

How do I use mySQL Workbench to backup a database?

  1. Open up mySQL Workbench
  2. Under "Server Administration", select an instance with the correct database privileges, otherwise create a New Server Instance with the correct privileges
    1. To create a new instance, click New Server Instance
    2. Select localhost if the mySQL service is installed on the local machine, otherwise select Remote Host
    3. Enter the username/password, click Next.
    4. Confirm your password and click OK
    5. Click Next on the Testing Database Connection step
    6. Click Next on the Set Windows configuration parameters for this machine step
    7. Click Next on the Testing Host Machine Settings step
    8. Click Continue if prompted for success on Reviewing your settings
    9. Type in a name to identify this instance... can be whatever; then click Finish
  3. Click on Data Export under DATA EXPORT / RESTORE
  4. Under the Object Select tab, select the backup method you would like to use "Export to Dump Project Folder" or "Export to Self-Contained File" and click the Start Export button.

How to remove print drivers in Windows 7

Inside of Windows 7, you will need to use the printui.exe utility. Before proceeding, I would recommend removing your printer from the Devices and Printers area to prevent issues from removing the driver itself.

  1. Open up a command prompt with Administrator privileges
  2. Execute: printui /s /t2
  3. Select the Drivers tab inside the Print Server Properties dialog box
  4. Select the print driver you would like to remove and click Remove...
  5. Check Remove driver and driver package.
  6. Click OK

You can now reinstall the printer successfully by using group policy (if you have you have a print server) or manually with the installation wizards.