Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Stop the process if download fails. #11

Closed
jasondinh opened this issue Dec 1, 2014 · 11 comments
Closed

Stop the process if download fails. #11

jasondinh opened this issue Dec 1, 2014 · 11 comments
Labels

Comments

@jasondinh
Copy link

I'm using PEM to generate multiple certificates for multiple targets. Sometimes the download failed but you always copy /tmp/PEM/pem_temp.pem without checking, I ended up with a duplicate certificate.

INFO [2014-12-01 12:04:24.31]: Refreshing push notification profiles for app '[RETRACTED]'
INFO [2014-12-01 12:04:27.71]: Login into iOS Developer Center
INFO [2014-12-01 12:04:41.32]: Login successful
INFO [2014-12-01 12:04:45.43]: Push for app '[RETRACTED]' is enabled
WARN [2014-12-01 12:04:46.46]: Push for app '[RETRACTED]' is enabled, but there is no development certificate yet.
INFO [2014-12-01 12:04:49.53]: Couldn't find a signing certificate in the current folder. Creating one for you now.
INFO [2014-12-01 12:04:49.67]: Successfully generated .certSigningRequest at path '/tmp/PEM/PEMCertificateSigningRequest.certSigningRequest'
DEBUG [2014-12-01 12:04:49.71]: Waiting for iTC to generate the profile
DEBUG [2014-12-01 12:04:51.72]: Waiting for iTC to generate the profile
DEBUG [2014-12-01 12:04:53.73]: Waiting for iTC to generate the profile
DEBUG [2014-12-01 12:04:55.73]: Waiting for iTC to generate the profile
DEBUG [2014-12-01 12:04:57.74]: Waiting for iTC to generate the profile
INFO [2014-12-01 12:04:59.74]: Going to download the latest profile
https://developer.apple.com/account/ios/certificate/certificateContentDownload.action?displayId=BXT34RV39G&type=BKLRAVXMGM
INFO [2014-12-01 12:05:03.92]: Successfully downloaded latest .cer file.
openssl x509 -inform der -in '/tmp/PEM//aps_development_[RETRACTED].cer' -out /tmp/PEM/pem_temp.pem
unable to load certificate
25074:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:/SourceCache/OpenSSL098/OpenSSL098-52/src/crypto/asn1/tasn_dec.c:1315:
25074:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:/SourceCache/OpenSSL098/OpenSSL098-52/src/crypto/asn1/tasn_dec.c:379:Type=X509
./development_[RETRACTED].pem
@KrauseFx
Copy link
Contributor

KrauseFx commented Dec 1, 2014

What do you suggest? Clearing up the temporary folder before running again?

@jasondinh
Copy link
Author

I think I misunderstood this problem. The download fails but it's currently filed under #13. This is a problem when the .cer could not be loaded.

Clearing the /tem/PEM folder would be unnecessary, you could use unique name for the .pem file and only remove that file before generate new file.

@jasondinh
Copy link
Author

Or better yet, use unique name for every download to avoid this problem completely.

@alistra
Copy link

alistra commented Dec 1, 2014

In general you want to google for mktemp

http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html

@alistra
Copy link

alistra commented Dec 1, 2014

Actually this is not doubled by #13.

This happens independently. Sometimes the downloaded cert is just not valid.

INFO [2014-12-01 18:16:28.81]: Going to download the latest profile
https://developer.apple.com/account/ios/certificate/certificateContentDownload.action?displayId=2647EFLEQ4&type=3BQKVH9I2X
INFO [2014-12-01 18:16:32.45]: Successfully downloaded latest .cer file.
openssl x509 -inform der -in '/tmp/PEM//aps_production_<redacted>.cer' -out /tmp/PEM/pem_temp.pem
unable to load certificate
6350:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:/SourceCache/OpenSSL098/OpenSSL098-52/src/crypto/asn1/tasn_dec.c:1315:
6350:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:/SourceCache/OpenSSL098/OpenSSL098-52/src/crypto/asn1/tasn_dec.c:379:Type=X509

@alistra
Copy link

alistra commented Dec 1, 2014

You should check the validity of the cert and possibly retry the download?

@alistra
Copy link

alistra commented Dec 1, 2014

https://gist.github.com/anonymous/f4a5bcd71a41303ca066 the file that is downloaded during this bug is a html file, you can check file x.cer output, and if it says html try to retry

@KrauseFx
Copy link
Contributor

KrauseFx commented Dec 1, 2014

@alistra Thanks for the tip with Tempfile. Should use that. I'll refactor my tools to make use of this class instead.

@muffe
Copy link

muffe commented Jan 13, 2015

Since the original problem of this issue is fixed, should we close this and create a feature request for the naming of the temp files @KrauseFx?

@KrauseFx
Copy link
Contributor

Good idea, @muffe

@fastlanebot
Copy link

This issue was migrated to fastlane/fastlane#2841. Please post all further comments there.

fastlane is now a mono repo, you can read more about the change in our blog post. All tools are now available in the fastlane main repo 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants