Openssl is not recognized as an internal or external command

243,193

Solution 1

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

Solution 2

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.

Solution 3

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.

Solution 4

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**

Solution 5

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>
Share:
243,193

Related videos on Youtube

Khurram W. Malik
Author by

Khurram W. Malik

Updated on July 08, 2022

Comments

  • Khurram W. Malik
    Khurram W. Malik almost 2 years

    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?

    • Michael Petrotta
      Michael Petrotta over 11 years
      Download and install OpenSSL.
    • Khurram W. Malik
      Khurram W. Malik over 11 years
      I downloaded 3 of them no one is compatible :/
    • Michael Petrotta
      Michael Petrotta over 11 years
      What does that mean, khurram?
    • Khurram W. Malik
      Khurram W. Malik over 11 years
      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 require
    • Usama Sarwar
      Usama Sarwar over 11 years
      you can get it from the link I have posted in my ans below...
    • RBT
      RBT over 2 years
  • Akhil Jain
    Akhil Jain about 11 years
    it says c:\openssl\bin\openssl is not recognized
  • AnhSirk Dasarp
    AnhSirk Dasarp over 10 years
    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 is
  • phanhongphucit
    phanhongphucit over 10 years
    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" base64
  • surhidamatya
    surhidamatya over 10 years
    @LatentBoy yess you are right. your way worked for me. Thanks alot.
  • Azahar
    Azahar over 10 years
    must download openssl from here code.google.com/p/openssl-for-windows/downloads/… and copy bin folder and paste to C:\openssl\
  • Krupal Shah
    Krupal Shah over 9 years
    thanks...after trying about an hour, your answer worked for me
  • Harsha
    Harsha over 9 years
    can you suggest openssl for windows32bit plse
  • Usama Sarwar
    Usama Sarwar over 9 years
    @Harsha Please see the edit section, now it has got OPenSSL link for 32 bits as well.
  • PAA
    PAA over 7 years
    Usama : Could you please guide on the issue stackoverflow.com/questions/38935267/… ?
  • Neon Warge
    Neon Warge over 7 years
    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?
  • Jaime Montoya
    Jaime Montoya about 7 years
    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" base64
  • MetaSnarf
    MetaSnarf about 7 years
    does this work for release version of facebook? if not how?
  • Sagar Chavada
    Sagar Chavada about 7 years
    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.
  • Ionut
    Ionut over 6 years
    What bin folder are you refering to in the second step?
  • ralphgabb
    ralphgabb over 6 years
    '"C:\OpenSSL\bin.openssl.exe"' is not recognized as an internal or external command, operable program or batch file.
  • Someone Somewhere
    Someone Somewhere over 5 years
    FYI: Usually the debug.keystore password is just "android".
  • Someone Somewhere
    Someone Somewhere over 5 years
    FYI: Usually the debug.keystore password is just "android".
  • Yesha Shah
    Yesha Shah over 5 years
    Getting error " Both context and applicationId must be non-null", when used above code. @SagarChavada
  • Narendra_Nath
    Narendra_Nath over 2 years
    This worked.. Thank you
  • Paul Grei
    Paul Grei over 2 years
    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 base64
  • Devendra  Singraul
    Devendra Singraul over 2 years
    It is good idea to add path in system environment variable