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,178 Comments on “Add Google Play public key to a self generated p12

  1. [url=https://celebrex200.com/]celebrex[/url] [url=https://tadalafil20mg.com/]buy tadalafil[/url] [url=https://sildenafilcitrategenericviagra.com/]sildenafil citrate[/url] [url=https://metformin500.com/]metformin hcl 500 mg[/url] [url=https://lasix40.com/]order lasix[/url]

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

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

  4. [url=https://writemypaper.us.org/]write a paper[/url] [url=https://homeworkhelp.us.org/]homework[/url] [url=https://paperwriting.us.org/]can i pay someone to write my paper[/url] [url=https://writeanessay.us.com/]write an essay[/url] [url=https://academicwriting.us.org/]help writing paper[/url] [url=https://collegepapers.us.com/]writing homework help[/url] [url=https://paperwritingservices.us.org/]writing my paper[/url] [url=https://essaywriter.us.org/]essay[/url] [url=https://helpwithhomework.us.com/]pay to do homework website[/url] [url=https://papers.us.org/]sites that write papers for you[/url]

  5. [url=https://paperwriting.us.org/]paper writers[/url] [url=https://writemypaper.us.org/]school papers[/url] [url=https://papers.us.org/]top essay writing services[/url] [url=https://collegepapers.us.com/]online essay writing services[/url] [url=https://paperwritingservices.us.org/]paper writing[/url] [url=https://academicwriting.us.org/]help me write my story[/url] [url=https://homeworkhelp.us.org/]homework help online[/url] [url=https://helpwithhomework.us.com/]homework help[/url] [url=https://writeanessay.us.com/]write a essay[/url] [url=https://essaywriter.us.org/]essay[/url]

  6. [url=https://writemypaper.us.org/]write my paper for me[/url] [url=https://writeanessay.us.com/]argue essay[/url] [url=https://homeworkhelp.us.org/]homework help[/url] [url=https://helpwithhomework.us.com/]homework assistance pay later[/url] [url=https://paperwriting.us.org/]professional paper writing[/url]

  7. [url=https://xenicalcapsules.com/]xenical capsules[/url] [url=https://levitra911.com/]levitra[/url] [url=https://doxycycline100.com/]doxycycline[/url] [url=https://propecia5.com/]generic propecia 5mg[/url] [url=https://cialisq.com/]cialis[/url]

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

  9. [url=https://papers.us.org/]writing a journal article review[/url] [url=https://writeanessay.us.com/]write an essay[/url] [url=https://academicwriting.us.org/]academic writing[/url] [url=https://paperwriting.us.org/]cheap essay writing service[/url] [url=https://collegepapers.us.com/]write papers for me[/url]

  10. [url=https://paperwriting.us.org/]college paper writing[/url] [url=https://writeanessay.us.com/]write an essay[/url] [url=https://helpwithhomework.us.com/]college homework help[/url] [url=https://papers.us.org/]college paper[/url] [url=https://writemypaper.us.org/]best essay writing service reviews[/url]

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

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

  13. [url=https://collegepapers.us.com/]college papers[/url] [url=https://writeanessay.us.com/]writing compare and contrast essay[/url] [url=https://homeworkhelp.us.org/]online homework help[/url] [url=https://academicwriting.us.org/]write a paper[/url] [url=https://helpwithhomework.us.com/]help with homework[/url]

  14. [url=https://albendazoletablets.com/]albendazole 400 mg[/url] [url=https://tadacip2019.com/]buy tadacip[/url] [url=https://buyzithromaxonline.com/]zithromax buy[/url] [url=https://antabuse250.com/]antabus[/url] [url=https://celebrex200.com/]celebrex[/url]

  15. [url=https://writemypaper.us.org/]write a paper for me[/url] [url=https://essaywriter.us.org/]transfer college essay[/url] [url=https://homeworkhelp.us.org/]homework help[/url] [url=https://paperwritingservices.us.org/]paper writing services[/url] [url=https://papers.us.org/]cheap paper writing[/url]

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

  17. [url=https://paperwriting.us.org/]writing paper online[/url] [url=https://paperwritingservices.us.org/]paper writing[/url] [url=https://writeanessay.us.com/]custom essay writing rhetorical analysis[/url] [url=https://collegepapers.us.com/]write my papers[/url] [url=https://writemypaper.us.org/]write my paper[/url]

Leave a Reply

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