Skip to content

Commit

Permalink
Add support for optionally explaining why inapplicable certificates a…
Browse files Browse the repository at this point in the history
…re not applicable. Partially fixes #58251.

This also requires a Xamarin.MacDev bump:

xamarin/Xamarin.MacDev@f83f84d Add support for optionally explaining why inapplicable provisioning profiles are not applicable. Partially fixes #58251. (xamarin#16)
xamarin/Xamarin.MacDev@d60d25b Added new iPhone X icon sizes

https://bugzilla.xamarin.com/show_bug.cgi?id=58251
  • Loading branch information
rolfbjarne committed Oct 9, 2017
1 parent 3091cf6 commit ee5e6b6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
2 changes: 1 addition & 1 deletion external/Xamarin.MacDev
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,17 @@ bool TryGetSigningCertificates (SecKeychain keychain, out IList<X509Certificate2
{
var now = DateTime.Now;

certs = keychain.FindNamedSigningCertificates (x => StartsWithAny (x, prefixes)).Where (x => now < x.NotAfter).ToList ();
certs = keychain.FindNamedSigningCertificates (x => {
var rv = StartsWithAny (x, prefixes);
if (!rv)
Log.LogMessage (MessageImportance.Low, "The certificate '{0}' does not match any of the prefixes '{1}'.", x, string.Join ("', '", prefixes));
return rv;
}).Where (x => {
var rv = now < x.NotAfter;
if (!rv)
Log.LogMessage (MessageImportance.Low, "The certificate '{0}' has expired ({1})", Xamarin.MacDev.Keychain.GetCertificateCommonName (x), x.NotAfter);
return rv;
}).ToList ();

if (certs.Count == 0 && !allowZeroCerts) {
var message = "No valid " + PlatformName + " code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com.";
Expand All @@ -214,7 +224,17 @@ bool TryGetSigningCertificates (SecKeychain keychain, out IList<X509Certificate2
{
var now = DateTime.Now;

certs = keychain.FindNamedSigningCertificates (x => x == name).Where (x => now < x.NotAfter).ToList ();
certs = keychain.FindNamedSigningCertificates (x => {
var rv = x == name;
if (!rv)
Log.LogMessage (MessageImportance.Low, "The certificate '{0}' does not match '{1}'.", x, name);
return rv;
}).Where (x => {
var rv = now < x.NotAfter;
if (!rv)
Log.LogMessage (MessageImportance.Low, "The certificate '{0}' has expired ({1})", Xamarin.MacDev.Keychain.GetCertificateCommonName (x), x.NotAfter);
return rv;
}).ToList ();

if (certs.Count == 0) {
Log.LogError (PlatformName + " code signing key '{0}' not found in keychain.", SigningKey);
Expand Down Expand Up @@ -367,6 +387,12 @@ public override bool Execute ()
if (!TryGetSigningCertificates (out certs, false))
return false;

if (certs.Count > 0) {
Log.LogMessage (MessageImportance.Low, "Available certificates:");
foreach (var cert in certs)
Log.LogMessage (MessageImportance.Low, " {0}", Xamarin.MacDev.Keychain.GetCertificateCommonName (cert));
}

if (!IsAutoCodeSignProfile (ProvisioningProfile)) {
identity.Profile = MobileProvisionIndex.GetMobileProvision (platform, ProvisioningProfile);

Expand Down Expand Up @@ -408,15 +434,28 @@ public override bool Execute ()
return !Log.HasLoggedErrors;
}

List<string> failures = new List<string> ();
if (identity.BundleId != null) {
if (certs.Count > 0)
profiles = MobileProvisionIndex.GetMobileProvisions (platform, identity.BundleId, type, certs, unique: true);
profiles = MobileProvisionIndex.GetMobileProvisions (platform, identity.BundleId, type, certs, unique: true, failures: failures);
else
profiles = MobileProvisionIndex.GetMobileProvisions (platform, identity.BundleId, type, unique: true);
profiles = MobileProvisionIndex.GetMobileProvisions (platform, identity.BundleId, type, unique: true, failures: failures);
} else if (certs.Count > 0) {
profiles = MobileProvisionIndex.GetMobileProvisions (platform, type, certs, unique: true);
profiles = MobileProvisionIndex.GetMobileProvisions (platform, type, certs, unique: true, failures: failures);
} else {
profiles = MobileProvisionIndex.GetMobileProvisions (platform, type, unique: true, failures: failures);
}

if (profiles.Count == 0) {
foreach (var f in failures)
Log.LogMessage (MessageImportance.Low, "{0}", f);
Log.LogError ($"Could not find any available provisioning profiles for {PlatformName}.");
return false;
} else {
profiles = MobileProvisionIndex.GetMobileProvisions (platform, type, unique: true);
Log.LogMessage (MessageImportance.Low, "Available profiles:");
foreach (var p in profiles) {
Log.LogMessage (MessageImportance.Low, " {0}", p.Name);
}
}

List<CodeSignIdentity> pairs;
Expand Down

0 comments on commit ee5e6b6

Please sign in to comment.