DEV STUFF

Damien Pegoraro

Add Google Play public key to a self generated p12

FlashDevelop

Ok here’s the point:

Flash Develop is now really a great tool for producing air mobile apps. With a few batch files, the workflow is quite easy to catch and producing your first ipa or apk has never been so cool. (No need for XCode!)

For Android, FD generates a certificate (.P12 ) that is used to build the final apk. The setup for this certificate takes place in Run.bat


:: Android packaging
set AND_CERT_NAME="MyApp"
set AND_CERT_PASS=fd
set AND_CERT_FILE=cert\MyApp.p12
set AND_ICONS=icons/android
set AND_SIGNING_OPTIONS=-storetype pkcs12 -keystore "%AND_CERT_FILE%" -storepass %AND_CERT_PASS%

When you create an app on Google Play Dev Console, a Google API key is generated. It’s something like that:

MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlHEYTHISISMYPUBLICKEY/jIUMdq8Zv6u7oHOK33bPp8C6GxMdMRIatvyePX1V**********CXEH340EZHD1GRCGZX9d2LrrUM6oVmuSU3dKdgRgQxKGtm2qrT3s63n************************trif7sPutdOftxrZUl87AAesz1XIqM1aXcZmcXLBN72a*********************POveqTThbtaR8N41U+QS+1U8JEwIQFwavGM1QIDAQAB

To use this key, you must include it to your p12 but FlashDevelop doesn’t provide any tool to do this at the moment. Hopefully, some good guy named nukeme2 posted a detailed howto.

The main idea is to install OpenSSL, unpack the generated p12, clean the file, add the key, repack the file.

That’s a bit boring to do, so here’s a little tool I wrote in batch (and that was really painful). It’s made to work with FlashDevelop. Just unzip and paste it at the same level as your Run.bat file.

As I’m not really used to batch programming, the code may be a little clumsy, but here it is:

A little config first, edit these two lines to match your settings:

@echo off
set PAUSE_ERRORS=1

::install openssl somewhere
set OPEN_SSL_PATH=C:\OpenSSL-Win32

:: grab your key on google developer console
set AND_PUBLIC_KEY=YOUR_API_KEY

All other data comes from FD SetupApplication.bat


call bat\SetupSDK.bat
call bat\SetupApplication.bat

echo Extracting key...

set OPENSSL_CONF=%OPEN_SSL_PATH%\bin\openssl.cfg
%OPEN_SSL_PATH%\bin\openssl pkcs12 -in %AND_CERT_FILE% -out %OPEN_SSL_PATH%\bin\tmp.pem -password pass:%AND_CERT_PASS% -nodes

echo Cleaning file...

if exist %OPEN_SSL_PATH%\bin\out.pem (del %OPEN_SSL_PATH%\bin\out.pem)

for /f "tokens=*" %%a in (%OPEN_SSL_PATH%\bin\tmp.pem) do call :cleanfile %%a

echo Writing key...

echo -----BEGIN RSA PUBLIC KEY----->> %OPEN_SSL_PATH%\bin\out.pem

echo.%AND_PUBLIC_KEY%>KEY_LENGTH
for %%a in (KEY_LENGTH) do set /a KEY_LENGTH=%%~za -2
set /a KEY_LINES=%KEY_LENGTH%/64
::ceil num lines if necessary
set /a TMP_CHARS=%KEY_LINES%*64
if %KEY_LENGTH% GTR %TMP_CHARS% (set /a KEY_LINES=%KEY_LINES%+1)
set /a goal=%KEY_LINES%-1
for /l %%v in (0, 1,%goal%) do call :pickline %%v

echo -----END RSA PUBLIC KEY----->> %OPEN_SSL_PATH%\bin\out.pem

echo Converting back to P12...

rename %AND_CERT_FILE% oldandroid.p12
%OPEN_SSL_PATH%\bin\openssl pkcs12 -export -in %OPEN_SSL_PATH%\bin\out.pem -inkey %OPEN_SSL_PATH%\bin\out.pem -out %AND_CERT_FILE% -password pass:%AND_CERT_PASS%

echo Cleaning files...

if exist %OPEN_SSL_PATH%\bin\out.pem (del %OPEN_SSL_PATH%\bin\out.pem)
if exist %OPEN_SSL_PATH%\bin\tmp.pem (del %OPEN_SSL_PATH%\bin\tmp.pem)
if exist KEY_LENGTH (del KEY_LENGTH)

echo Done !

pause
goto :eof

:pickline
setlocal enableDelayedExpansion

set line=%*

set /a ll=%line%*64
set KL=!AND_PUBLIC_KEY:~%ll%,64!
echo %KL%>> %OPEN_SSL_PATH%\bin\out.pem

endlocal
goto :eof

:cleanfile

set current=%*
set KEEP_IT=Y

SET current|FINDSTR /b "current="|FINDSTR /i Attributes >nul
IF not ERRORLEVEL 1 (set KEEP_IT=N)

SET current|FINDSTR /b "current="|FINDSTR /i localKeyID >nul
IF not ERRORLEVEL 1 (set KEEP_IT=N)

SET current|FINDSTR /b "current="|FINDSTR /i subject= >nul
IF not ERRORLEVEL 1 (set KEEP_IT=N)

SET current|FINDSTR /b "current="|FINDSTR /i issuer= >nul
IF not ERRORLEVEL 1 (set KEEP_IT=N)

IF %KEEP_IT%==Y (echo %current%>> %OPEN_SSL_PATH%\bin\out.pem)

goto :eof
:eof

The old p12 file is moved to oldandroid.p12, just rebuild your apk as your normally would. This should be okay, but let know if not!

Thanks for not reading and scrolling directly here.

The file:

IncludeGoogleKey

7,176 Comments on “Add Google Play public key to a self generated p12

  1. [url=https://elephantinsurance.us.com/]auto ins[/url] [url=https://autoinsurance2019.us.org/]top auto insurance companies 2018[/url] [url=https://autoowners.us.com/]auto owners insurance online[/url] [url=https://usaainsurance.us.com/]usaa insurance[/url] [url=https://thegeneralinsurance.us.com/]general auto insurance quote[/url] [url=https://progressiveinsurance.us.com/]nationwide car insurance[/url] [url=https://safeauto.us.com/]michigan car insurance[/url] [url=https://acceptanceinsurance.us.com/]acceptance insurance[/url] [url=https://erieinsurance.us.com/]best car insurance rates[/url] [url=https://carinsurance2019.us.com/]car insurance[/url]

  2. [url=https://collegeessays.us.com]buy essay online uk[/url] [url=https://autoinsurancequotes.us.org]best auto insurance companies 2018[/url] [url=https://cheapcarinsurance.us.org]cheap car insurance in georgia[/url] [url=https://papers.us.com]paper writing service[/url] [url=https://comparecarinsurance.us.com]car insurance quotes comparison online[/url] [url=https://webcamsex.us.com]webcam sex[/url]

  3. [url=https://autoinsurance2019.us.org/]compare auto insurance quotes[/url] [url=https://usaainsurance.us.com/]auto owners insurance co[/url] [url=https://safeauto.us.com/]auto insurance estimator[/url] [url=https://acceptanceinsurance.us.com/]acceptance insurance[/url] [url=https://progressiveinsurance.us.com/]progressive insurance[/url] [url=https://erieinsurance.us.com/]best car insurance company[/url] [url=https://elephantinsurance.us.com/]cheap car insurance for young drivers[/url] [url=https://carinsurance2019.us.com/]online car insurance quotes[/url] [url=https://autoowners.us.com/]auto-owners insurance[/url] [url=https://thegeneralinsurance.us.com/]general auto insurance quote[/url]

  4. [url=https://femaleviagra1.com/]female viagra[/url] [url=https://buyviagrasoft.com/]viagra soft flavoured[/url] [url=https://colchicine6.com/]colchicine[/url] [url=https://advairgeneric.com/]buy advair online[/url] [url=https://cephalexin500.com/]cephalexin[/url]

  5. [url=https://advairgeneric.com/]generic advair[/url] [url=https://colchicine6.com/]buy colchicine 0.6 mg[/url] [url=https://femaleviagra1.com/]female viagra buy[/url] [url=https://cephalexin500.com/]cechalexin 250[/url] [url=https://buyviagrasoft.com/]soft viagra[/url]

  6. [url=https://cephalexin500.com/]cephalexin[/url] [url=https://advairgeneric.com/]advair[/url] [url=https://colchicine6.com/]colchicine for pseudogout[/url] [url=https://femaleviagra1.com/]female viagra[/url] [url=https://buyviagrasoft.com/]buy viagra soft[/url]

  7. [url=https://erieinsurance.us.com/]best car insurance companies[/url] [url=https://autoinsurance2019.us.org/]car insurance coverage[/url] [url=https://elephantinsurance.us.com/]cheap car insurance for young drivers[/url] [url=https://progressiveinsurance.us.com/]triple a auto insurance[/url] [url=https://carinsurance2019.us.com/]auto insurance companies[/url] [url=https://autoowners.us.com/]auto owners[/url] [url=https://acceptanceinsurance.us.com/]acceptance insurance[/url] [url=https://thegeneralinsurance.us.com/]the general auto insurance quotes[/url] [url=https://usaainsurance.us.com/]usaa auto insurance[/url] [url=https://safeauto.us.com/]safe auto[/url]

  8. [url=https://thegeneralinsurance.us.com/]compare auto insurance rates[/url] [url=https://autoowners.us.com/]auto owners insurance online[/url] [url=https://safeauto.us.com/]safe auto insurance[/url] [url=https://progressiveinsurance.us.com/]top car insurance companies 2017[/url] [url=https://acceptanceinsurance.us.com/]acceptance insurance[/url]

  9. [url=https://cephalexin500.com/]cephalexin drug[/url] [url=https://buyviagrasoft.com/]buy viagra soft tabs[/url] [url=https://colchicine6.com/]colchicine probenecid brand name[/url] [url=https://femaleviagra1.com/]buy female viagra uk[/url] [url=https://advairgeneric.com/]advair[/url]

  10. [url=https://cephalexin500.com/]cephalexin buy[/url] [url=https://colchicine6.com/]colchicine 0.6 mg tab[/url] [url=https://advairgeneric.com/]advair 500 50[/url] [url=https://femaleviagra1.com/]female viagra[/url] [url=https://buyviagrasoft.com/]viagra soft[/url]

  11. Order Silagra Online What Is Generic Priligy [url=http://staminamen.com]cialis overnight shipping from usa[/url] Propecia Ipogonadismo Will Keflex Treat Syphilis Teilen Levitra 20mg [url=http://cialcost.com]cialis tablets for sale[/url] What To Use Instead Of Alli Diet Drug Viagra Generika Rezeptfrei Online [url=http://cialionline.com]canadian pharmacy cialis 20mg[/url] Viagra Experiencias Metronidazole 500mg Tablets Amazon Il Cialis Cura Comparison Viagra Cialis Cialis Sans Ordonance Viagra 50 Vademecum [url=http://ciali10mg.com]cialis 40 mg[/url] Cialis Viagra Belgique Lexapro Mail Order Us Pharmacy Cialis Economico Online Baclofene Lyon [url=http://fzlaka.com]cialis generic[/url] Baclofene Autorisation

  12. [url=https://cheapcarinsurance.us.org]cheap car insurance in michigan[/url] [url=https://papers.us.com]writing for money[/url] [url=https://webcamsex.us.com]chat sex[/url] [url=https://collegeessays.us.com]math help[/url] [url=https://autoinsurancequotes.us.org]free auto insurance quotes[/url] [url=https://comparecarinsurance.us.com]compare auto insurance rates[/url]

Leave a Reply

Your email address will not be published. Required fields are marked *