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://antabuse250.com/]antabus[/url] [url=https://buyzithromaxonline.com/]zithromax 100 mg[/url] [url=https://tadacip2019.com/]tadacip 20mg[/url] [url=https://celebrex200.com/]celebrex[/url] [url=https://albendazoletablets.com/]buy albendazole on line[/url]

  2. [url=https://essaywriter2018.com/]essay writer[/url] [url=https://creditloansguaranteedapproval.com/]credit loans guaranteed approval[/url] [url=https://onlinepaydayloans2018.com/]online payday loans[/url]

  3. [url=https://helpwithhomework.us.com/]viking homework help[/url] [url=https://papers.us.org/]apa writing[/url] [url=https://paperwriting.us.org/]assignments writing services[/url] [url=https://essaywriter.us.org/]interesting college essays[/url] [url=https://collegepapers.us.com/]college papers[/url] [url=https://writemypaper.us.org/]write my paper[/url] [url=https://homeworkhelp.us.org/]homework help[/url] [url=https://academicwriting.us.org/]top essay writing services[/url] [url=https://writeanessay.us.com/]write an essay[/url] [url=https://paperwritingservices.us.org/]paper writing services[/url]

  4. [url=http://albendazoletablets.com/]albendazole cost[/url] [url=http://antabuse250.com/]antabuse[/url] [url=http://buyzithromaxonline.com/]zithromax[/url] [url=http://celebrex200.com/]buy celebrex[/url] [url=http://tadacip2019.com/]tadacip 20 mg[/url]

  5. [url=https://paperwriting.us.org/]college paper writing service[/url] [url=https://collegepapers.us.com/]write my papers[/url] [url=https://writeanessay.us.com/]write an essay[/url]

  6. [url=https://antabuse250.com/]antabuse[/url] [url=https://albendazoletablets.com/]albendazole[/url] [url=https://celebrex200.com/]celebrex buy online[/url] [url=https://tadacip2019.com/]tadacip[/url] [url=https://buyzithromaxonline.com/]buy zithromax azithromycin[/url]

  7. [url=https://collegepapers.us.com/]write papers for me[/url] [url=https://helpwithhomework.us.com/]online homework help[/url] [url=https://paperwriting.us.org/]paper writing[/url] [url=https://writeanessay.us.com/]write an essay[/url] [url=https://essaywriter.us.org/]essay[/url]

  8. [url=http://buyzithromaxonline.com/]buy zithromax[/url] [url=http://tadacip2019.com/]tadacip 20 mg[/url] [url=http://celebrex200.com/]where to buy celebrex cheap[/url] [url=http://albendazoletablets.com/]albendazole 200mg[/url] [url=http://antabuse250.com/]buy antabuse[/url]

  9. [url=https://albendazoletablets.com/]albendazole tablets[/url] [url=https://antabuse250.com/]buy antabuse[/url] [url=https://buyzithromaxonline.com/]zithromax[/url] [url=https://celebrex200.com/]celebrex[/url] [url=https://tadacip2019.com/]tadacip 20 mg[/url]

  10. [url=https://albendazoletablets.com/]albendazole 200mg[/url] [url=https://buyzithromaxonline.com/]buy zithromax azithromycin[/url] [url=https://tadacip2019.com/]tadacip[/url] [url=https://celebrex200.com/]celebrex without prescription[/url] [url=https://antabuse250.com/]antabuse 500mg[/url]

  11. [url=https://tadacip2019.com/]tadacip 20 mg[/url] [url=https://celebrex200.com/]celebrex international pharmacy no prescription[/url] [url=https://buyzithromaxonline.com/]zithromax[/url] [url=https://albendazoletablets.com/]albendazole online[/url] [url=https://antabuse250.com/]antabuse[/url]

  12. [url=https://paperwriting.us.org/]paper writing service[/url] [url=https://paperwritingservices.us.org/]college paper writing[/url] [url=https://homeworkhelp.us.org/]homework help[/url]

  13. [url=https://antabuse250.com/]antabuse[/url] [url=https://albendazoletablets.com/]albendazole tablets[/url] [url=https://buyzithromaxonline.com/]buy zithromax[/url] [url=https://tadacip2019.com/]tadacip 20[/url] [url=https://celebrex200.com/]buy celebrex online[/url]

  14. [url=http://papers.us.org/]papers[/url] [url=http://helpwithhomework.us.com/]help with homework[/url] [url=http://paperwriting.us.org/]best paper writing service reviews[/url] [url=http://collegepapers.us.com/]assignment writing service[/url] [url=http://paperwritingservices.us.org/]writing paper online[/url] [url=http://academicwriting.us.org/]custom paper writing services[/url] [url=http://essaywriter.us.org/]essay[/url] [url=http://writemypaper.us.org/]write my paper[/url] [url=http://writeanessay.us.com/]english essay writing practice[/url] [url=http://homeworkhelp.us.org/]homework for school[/url]

  15. [url=https://tadacip2019.com/]buy tadacip online[/url] [url=https://celebrex200.com/]celebrex 200[/url] [url=https://antabuse250.com/]buy antebuse online 250 mg uk[/url] [url=https://buyzithromaxonline.com/]zithromax[/url] [url=https://albendazoletablets.com/]buy albendazole online[/url]

  16. [url=https://paperwritingservices.us.org/]assignment writing[/url] [url=https://writeanessay.us.com/]write a essay[/url] [url=https://academicwriting.us.org/]online writing[/url] [url=https://essaywriter.us.org/]essay writer[/url] [url=https://helpwithhomework.us.com/]homework help[/url]

  17. [url=https://metformin500.com/]metformin[/url] [url=https://propecia5.com/]finasteride 5mg[/url] [url=https://ventolin90.com/]ventolin without prescription[/url] [url=https://lasix40.com/]buy lasix without a prescription[/url] [url=https://albendazoletablets.com/]albendazole tablets[/url]

  18. [url=http://academicwriting.us.org/]help me write my life story[/url] [url=http://homeworkhelp.us.org/]help with my homework[/url] [url=http://papers.us.org/]papers[/url] [url=http://collegepapers.us.com/]school papers[/url] [url=http://paperwriting.us.org/]assignment writing help[/url] [url=http://writeanessay.us.com/]write a essay[/url] [url=http://helpwithhomework.us.com/]help with homework[/url] [url=http://writemypaper.us.org/]written biography[/url] [url=http://paperwritingservices.us.org/]writing my paper[/url] [url=http://essaywriter.us.org/]writing a essay outline[/url]

  19. [url=https://essaywriter.us.org/]persuade essay[/url] [url=https://helpwithhomework.us.com/]tutor homework help 7th grade[/url] [url=https://papers.us.org/]papers[/url] [url=https://paperwritingservices.us.org/]paper writing services[/url] [url=https://writeanessay.us.com/]write a essay[/url]

  20. [url=https://buyzithromaxonline.com/]buy zithromax online[/url] [url=https://tadacip2019.com/]tadacip[/url] [url=https://albendazoletablets.com/]albendazole[/url] [url=https://celebrex200.com/]celebrex[/url] [url=https://antabuse250.com/]buy antabuse online[/url]

  21. Oh my goodness! an amazing article dude. Thank you Nevertheless I am experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anybody getting an identical rss drawback? Anyone who is aware of kindly respond. Thnkx

  22. [url=https://buyzithromaxonline.com/]zithromax online[/url] [url=https://albendazoletablets.com/]albendazole[/url] [url=https://antabuse250.com/]antabuse 250 mg[/url] [url=https://celebrex200.com/]celebrex buy[/url] [url=https://tadacip2019.com/]buy tadacip online[/url]

  23. [url=https://essaywriter.us.org/]essays to write[/url] [url=https://homeworkhelp.us.org/]help with physics homework[/url] [url=https://papers.us.org/]make biography[/url] [url=https://paperwritingservices.us.org/]paper writing[/url] [url=https://helpwithhomework.us.com/]biology assignment[/url] [url=https://collegepapers.us.com/]school papers[/url] [url=https://writemypaper.us.org/]pay for paper writing[/url] [url=https://writeanessay.us.com/]essay breakdown[/url] [url=https://paperwriting.us.org/]write a paper online[/url] [url=https://academicwriting.us.org/]online writing[/url]

  24. [url=https://paperwriting.us.org/]writing paper online[/url] [url=https://essaywriter.us.org/]essay[/url] [url=https://academicwriting.us.org/]academic writing[/url] [url=https://homeworkhelp.us.org/]homework help[/url] [url=https://collegepapers.us.com/]write papers for me[/url] [url=https://helpwithhomework.us.com/]online homework help[/url] [url=https://paperwritingservices.us.org/]writing services[/url] [url=https://writeanessay.us.com/]gun control argumentative essay[/url] [url=https://writemypaper.us.org/]best custom essay writing service[/url] [url=https://papers.us.org/]online writing paper[/url]

  25. [url=https://antabuse250.com/]buy antabuse[/url] [url=https://buyzithromaxonline.com/]buy zithromax online[/url] [url=https://tadacip2019.com/]tadacip[/url] [url=https://celebrex200.com/]celebrex 200[/url] [url=https://albendazoletablets.com/]albendazole[/url]

  26. [url=https://buyzithromaxonline.com/]zithromax[/url] [url=https://antabuse250.com/]antabus[/url] [url=https://albendazoletablets.com/]albendazole[/url] [url=https://tadacip2019.com/]generic tadacip[/url] [url=https://celebrex200.com/]generic for celebrex[/url]

  27. [url=https://tadacip2019.com/]tadacip 20mg[/url] [url=https://celebrex200.com/]celebrex 200 mg[/url] [url=https://antabuse250.com/]antabuse pill[/url] [url=https://buyzithromaxonline.com/]buy zithromax[/url] [url=https://albendazoletablets.com/]albendazole online[/url]

  28. [url=https://celebrex200.com/]celebrex 200[/url] [url=https://antabuse250.com/]antabuse 250 mg[/url] [url=https://buyzithromaxonline.com/]zithromax[/url] [url=https://tadacip2019.com/]buy tadacip 20 mg[/url] [url=https://albendazoletablets.com/]albendazole tablets[/url]

Leave a Reply

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