Openssl is not recognized as an internal or external command
Asked Answered
K

24

226

I wish to generate an application signature for my app which will later be integrated with Facebook. In one of Facebook's tutorials, I found this command:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

In the tutorial, it says that by running this cmd, my process of generating the signature will start.

However, this command gives an error:

openssl is not recognized as an internal or external command

How can I get rid of this?

Keramics answered 10/8, 2012 at 6:4 Comment(6)
Download and install OpenSSL.Shilohshim
I downloaded 3 of them no one is compatible :/Keramics
What does that mean, khurram?Shilohshim
I downloaded many versions of openssl from the link u gave but each of them gives an error before installation that it isnt compatible with windows 7- 64 bit. Can you tell me the exact openssl i requireKeramics
you can get it from the link I have posted in my ans below...Coronet
Related post - How to install OpenSSL in windows 10?Youthful
C
441

Well at the place of OpenSSL ... you have to put actually the path to your OpenSSL folder that you have downloaded. Your actual command should look like this:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | "C:\Users\abc\openssl\bin\openssl.exe" sha1 -binary | "C:\Users\abc\openssl\bin\openssl.exe" base64

Remember, the path that you will enter will be the path where you have installed the OpenSSL.

Edit:

you can download OpenSSL for windows 32 and 64 bit from the respective links below:

OpenSSL for 64 Bits

OpenSSL for 32 Bits

Coronet answered 10/8, 2012 at 6:15 Comment(13)
it says c:\openssl\bin\openssl is not recognizedConidiophore
a better way would be to execute the original command from openssl/bin directory. I.e if my openssl directory is in C:dev, I would move to C:\dev\openssl\bin, and execute the command as it isBadinage
you should point out the openssl.exe file: exportcert -alias androiddebugkey -keystore ~/.android /debug.keystore | "C:\openssl\bin\openssl.exe" sha1 -binary | "C:\openssl\bin\op enssl.exe" base64Thermoelectricity
@LatentBoy yess you are right. your way worked for me. Thanks alot.Isometropia
thanks...after trying about an hour, your answer worked for meAbirritate
can you suggest openssl for windows32bit plseInflammable
@Inflammable Please see the edit section, now it has got OPenSSL link for 32 bits as well.Coronet
Usama : Could you please guide on the issue #38935767 ?Couching
The download links available seems to be source files and so it doesn't contain binary files which I believe I may have to build myself out of the box. Where can I get the official binary files?Phototype
It should be something like this: C:\Program Files\Java\jre1.8.0_111\bin>keytool -exportcert -alias androiddebugkey -keystore C:\Users\jaimemontoya\.android\debug.keystore | "C:\Program Files (x86)\GnuWin32\bin\openssl.exe" sha1 -binary | "C:\Program Files (x86)\GnuWin32\bin\openssl.exe" base64Appearance
'"C:\OpenSSL\bin.openssl.exe"' is not recognized as an internal or external command, operable program or batch file.Brockwell
FYI: Usually the debug.keystore password is just "android".Stoneware
Remove double quotes and it will work :) like so : keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | C:\openssl\bin\openssl.exe sha1 -binary | C:\openssl\bin\openssl.exe base64Azide
L
36

Please follow these step, I hope your key working properly:

  1. Step 1 You will need OpenSSL. You can download the binary from openssl-for-windows project on Google Code.

  2. Step 2 Unzip the folder, then copy the path to the bin folder to the clipboard.

    For example, if the file is unzipped to the location C:\Users\gaurav\openssl-0.9.8k_WIN32, then copy the path C:\Users\gaurav\openssl-0.9.8k_WIN32\bin.

  3. Step 3 Add the path to your system environment path. After your PATH environment variable is set, open the cmd and type this command:

    C:\>keytool -exportcert -alias androiddebugkey -keystore [path to debug.keystore] | openssl sha1 -binary | openssl base64
    

    Type your password when prompted. If the command works, then you will be shown a key.

Lid answered 28/4, 2013 at 14:7 Comment(2)
FYI: Usually the debug.keystore password is just "android".Stoneware
It is good idea to add path in system environment variableMissie
C
25

Use the entire path, like this:

exportcert -alias androiddebugkey -keystore ~/.android
/debug.keystore | "C:\openssl\bin\openssl.exe" sha1 -binary | "C:\openssl\bin\op
enssl.exe" base64

It worked for me.

Churlish answered 29/3, 2013 at 3:20 Comment(0)
A
12

it's late answer but it will help to lazy people like me.. add this code to your Application class, there is no need to download openssl and no need to set the path.. only need is just copy this code.. and keyHash will generated in log.

import com.facebook.FacebookSdk;
public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FacebookSdk.sdkInitialize(getApplicationContext());
        AppEventsLogger.activateApp(this);
        printKeyHash();
    }

    private void printKeyHash() {
        try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.i("KeyHash:",
                        Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.e("jk", "Exception(NameNotFoundException) : " + e);
        } catch (NoSuchAlgorithmException e) {
            Log.e("mkm", "Exception(NoSuchAlgorithmException) : " + e);
        }
    }
}

and do not forget add MyApplication class in manifest:

<application
        android:name=".MyApplication"
</application>
Acupuncture answered 5/8, 2016 at 6:6 Comment(3)
does this work for release version of facebook? if not how?Isham
This code is used to generate keyhash. And its same key for release too. For release version make sure that you set public access in facebook developer console.Acupuncture
Getting error " Both context and applicationId must be non-null", when used above code. @SagarChavadaMarquisette
C
11

This is worked for me successfully.

"C:\Program Files\Java\jdk1.6.0_26\bin\keytool.exe" -exportcert -alias sociallisting -keystore "D:\keystore\SocialListing" | "C:\cygwin\bin\openssl.exe" sha1 -binary | "C:\cygwin\bin\openssl.exe" base64

Be careful with below path :

  • "C:\Program Files\Java\jdk1.6.0_26\bin\keytool.exe"
  • "D:\keystore\SocialListing" or it can be like this "C:\Users\Shaon.android\debug.keystore"
  • "C:\cygwin\bin\openssl.exe" or can be like this C:\Users\openssl\bin\openssl.exe

If command successfully work then you will see this command :

Enter keystore password : typeyourpassword

Encryptedhashkey**

Cultivator answered 8/9, 2012 at 2:7 Comment(0)
V
8

If you are on windows and if you have git installed then you can run the open ssl command using GIT Bash.

  1. go to the directory where you want to store the key

  2. Right-click and open the GIT Bash

  3. Here you can run any openssl command. e.g.

    openssl enc -aes-128-cbc -k test -P -md sha1

Vaivode answered 29/6, 2022 at 10:18 Comment(0)
H
6

First navigate to your Java/jre/bin folder in cmd cd c:\Program Files (x86)\Java\jre7\bin

Then use : [change debug.keystore path to the correct location on your system] install openssl (for windows 32 or 64 as per your needs at c:\openssl )

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\vibhor\.android\debug.keystore" | "c:\openssl\bin\openssl.exe" sha1 -binary | "c:\openssl\bin\openssl.exe" base64

So the whole command goes like this : [prompts to enter keystore password on execution ]

c:\Program Files (x86)\Java\jre7\bin>keytool -exportcert -alias androiddebugkey
-keystore "C:\Users\vibhor\.android\debug.keystore" | "c:\openssl\bin\openssl.ex
e" sha1 -binary | "c:\openssl\bin\openssl.exe" base64
Enter keystore password:
Hushhush answered 12/8, 2014 at 6:8 Comment(0)
S
6
Steps to create Hash Key. 
1: Download openssl from Openssl for Windows . I downloaded the Win64 version 
2:Unzip and copy all the files in the bin folder including openssl.exe(All file of bin folder) 
3:Goto to the folder where you installed JDK for me it’s C:\Program Files\Java\jdk1.8.0_05\bin 
4:Paste all the files you copied from Openssl’s bin folder to the Jdk folder. 

then go C:\Program Files\Java\jdk1.8.0_05\bin and press shift key and right click and open cmd

C:\Program Files\Java\jdk1.8.0_05\bin>//cmd path 

that is for Sha1 past this
keytool -exportcert -alias androiddebugkey -keystore "C:\User\ABC\.android.keystore" | openssl sha1 -binary | openssl base64
//and ABC is system name put own system name

Savarin answered 13/5, 2015 at 18:50 Comment(1)
What bin folder are you refering to in the second step?Vivian
C
2

I used this code:

This is worked for me successfully.

"C:\Program Files\Java\jdk1.6.0_26\bin\keytool.exe" -exportcert -alias sociallisting -
keystore "D:\keystore\SocialListing" | "C:\cygwin\bin\openssl.exe" sha1 -binary | 
"C:\cygwin\bin\openssl.exe" base64
Colson answered 9/4, 2013 at 8:51 Comment(0)
E
2

Downloads and Unzip

You can download openssl for windows 32 and 64 bit from the respective links below:

https://code.google.com/archive/p/openssl-for-windows/downloads

OpenSSL for 64 Bits OpenSSL for 32 Bits

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | **"C:\Users\keshav.gera\openssl-0.9.8k_X64\bin**\openssl.exe" sha1 -binary | **"C:\Users\keshav.gera\openssl-0.9.8k_X64\bin**\openssl.exe" base64

Important change our path Here as well as install open ssl in your system

It's Working No Doubt

C:\Users\keshav.gera>keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | "C:\Users\keshav.gera\openssl-0.9.8k_X64\bin\openssl.exe" sha1 -binary | "C:\Users\keshav.gera\openssl-0.9.8k_X64\bin\openssl.exe" base64

Enter keystore password: android

**ZrRtxw36xWNYL+h3aJdcCeQQxi0=**

=============================================================

using Manually through Coding

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


private void PrintHashKey() {

        try {
            PackageInfo info = getPackageManager().getPackageInfo("**com.keshav.patanjalidemo  Your Package Name Here**", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");        
                md.update(signature.toByteArray());
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

    }
Epigraphic answered 26/5, 2017 at 11:2 Comment(0)
B
2

IDK if this is relevant here, but if you have Git Installed, you can find the openssl in the "C:\Program Files\Git\usr\bin" and that location you can use in the Terminal for your Keystore Command.

oh and yeah the command:

keytool -exportcert -alias keystore -keystore "C:\Users\YOURPATH/filename.jks" | "C:\Program Files\Git\usr\bin\openssl" sha1 -binary | "C:\Program Files\Git\usr\bin\openssl" base64

Bassist answered 30/11, 2020 at 10:3 Comment(1)
This worked.. Thank youSomme
B
1

use this worked for me. please change your Path

C:\Program Files\Java\jre7\bin keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Ace.android\debug.keystore" | "C:\openssl\bin

\openssl.exe" sha1 -binary | "C:\openssl\bin\openssl.exe" base64

Barbarous answered 23/11, 2013 at 11:58 Comment(1)
must download openssl from here code.google.com/p/openssl-for-windows/downloads/… and copy bin folder and paste to C:\openssl\Barbarous
D
0

For those looking for a more recent location to install a windows binary version of openssl (32bit and 64bit) you can find it here:

http://slproweb.com/products/Win32OpenSSL.html

An up to date list of websites that offer binary distributions is here

http://www.openssl.org/related/binaries.html

Dennis answered 8/11, 2012 at 12:0 Comment(0)
I
0

It is not guaranteed that generating hashkey with this single openssl method will work. If it does not work for me. But thanks for giving me a direction to solve my issue.

Guaranteed Solution : You need to break the whole command in separate commands and have to write output of every execution in file.

You can take the help from the following link :

http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1

Enjoy :)

Irascible answered 2/5, 2013 at 10:11 Comment(0)
M
0

go to bin folder path in cmd and then run following command

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

you will get your key hash

Maravedi answered 30/9, 2014 at 6:8 Comment(0)
T
0

for windows users download open ssl from google's code repository https://code.google.com/p/openssl-for-windows/downloads/list

After the download, extract the contents to a folder preferably in your c: drive.

Then update your PATH environment variable so you can use the .exe from any location in your command line.

[windows 8] To update your PATH environment variable, click my computer->properties->Advanced System Settings.

Click the Advanced Tab and click the 'Environment Variable' button at the bottom of the dialog then select the Path entry from the 'System Variables' Section by clicking edit.

Paste the path to the bin folder of the extracted openssl download and click ok.

You will need to close and open and command prompt you may have previously launched so that you can load the updated path settings.

Now run this command:

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Oladipo.android\debug.keystore" | openssl sha1 -binary | openssl base64

You should see the developer key.

Theme answered 20/11, 2014 at 19:44 Comment(0)
P
0

This works for me:

C:\Users\example>keytool -exportcert -alias androiddebugkey -keystore 
"C:\Users\example\.android" | "C:\openssl\bin\openssl.exe" sha1 -binary 
| "C:\openssl\bin\oenssl.exe" base64
Passim answered 9/9, 2017 at 5:5 Comment(0)
B
0

For those who arrive lost as I was now, follow Usama Sarwar response but if:

"your_openssl_path/bin/openssl.exe"

doesn't work, try it

your_openssl_path/bin/openssl.exe.

Without the quotes.

"c:\openssl\bin\openssl.exe" => Didn't work for me

c:\openssl\bin\openssl.exe => Worked for me

Benoit answered 3/7, 2021 at 21:32 Comment(0)
C
0

I've got the same issue today, solved it by following this video (the SSL installation) - https://www.youtube.com/watch?v=PoAc1lpfK8I&ab_channel=GleyGames

Then, i've took Usamas command, and run it (after changing the paths in the command), I've run it FROM inside the bin folder inside the java installation, using CMD.

full command that worked for me:

(from inside C:\Program Files\Java\jdk-11.0.12\bin) :

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\USERNAME\.android\debug.keystore" | "C:\Program Files\OpenSSL-Win64\bin\openssl" sha1 -binary | "C:\Program Files\OpenSSL-Win64\bin\openssl" base64
Chemistry answered 29/11, 2021 at 16:23 Comment(0)
I
0

Step 1

Download SSL for windows at https://code.google.com/archive/p/openssl-for-windows/downloads.

Step 2

Unzip the folder to OpenSSL and paste it to "C:\Program Files".

Step 3

Add "C:\Program Files\OpenSSL\bin" to your environnement variables (Edit the system environnement variables > Environnement variables > Path > New). It will make openssl work in the terminal.

Step 4

Add "C:\Program Files\Android\Android Studio\jre\bin" to your environnement variables. It will make keytool work in the terminal.

Step 5

Open a terminal and execute :

keytool -exportcert -alias androiddebugkey -keystore .android\debug.keystore | openssl sha1 -binary | openssl base64

The password should be android.

Ingrowing answered 5/4, 2022 at 6:14 Comment(0)
D
0

use this

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | "C:\Users\DK\openssl-0.9.8d_X64\bin\openssl.exe" sha1 -binary | "C:\Users\DK\openssl-0.9.8d_X64\bin\openssl.exe" base64
Discomfort answered 7/4, 2022 at 11:34 Comment(0)
O
0

Easy solution if you have git installed locally. you can just open git bash, change directory where you want your keys will be generated and then run your command. it will work because git installs open ssl exe by default and your don't need to set path to your ssl exe manually each time you want to run it. it works for me and I hope it helps.

Oxpecker answered 29/6, 2022 at 1:27 Comment(0)
V
0

So I tried almost everything that was mentioned as a solution here but that didn't work for me. If you are on windows and have Git installed, just do the below and you will get it in a sec;

1. Open Git Bash
2.keytool -exportcert -alias authFB -keystore "c:\users\your name\.android\debug.keystore" | "C:\Program Files\Git\usr\bin\openssl.exe" sha1 -binary | "C:\Program Files\Git\usr\bin\openssl.exe" base64

enter image description here

Vierra answered 27/8, 2023 at 8:0 Comment(0)
S
0

If you're using Windows and have Git Bash installed, you can resolve this issue by running the command in Git Bash. Here's how you can do it:

  1. Open Git Bash.

  2. Navigate to the directory where you want to generate the application signature.

  3. Run the following command:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

You may need these as well:

  • Make sure you have installed Git Bash on your Windows system. You can download it from the official Git website: https://git-scm.com/download/win

  • Ensure that you're running the command in the correct directory. If you're not sure, you can use the pwd command to check the current working directory.

Stefanysteffane answered 31/1 at 15:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.