Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
PatoBeltran committed Dec 1, 2017
1 parent e980b08 commit 37f779d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,6 @@ public byte[] TimestampData(TimestampRequest request, ILogger logger, Cancellati
}
}

<<<<<<< HEAD
private static X509Chain GetTimestampCertChain(X509Certificate2 timestampSignerCertificate, X509Certificate2Collection additionalCertificates)
{
if (!SigningUtility.IsCertificateValid(timestampSignerCertificate, additionalCertificates, out var timestampCertChain, allowUntrustedRoot: false, checkRevocationMode: X509RevocationMode.Online))
{
throw new TimestampException(LogMessage.CreateError(
NuGetLogCode.NU3011,
string.Format(CultureInfo.CurrentCulture,
Strings.TimestampCertificateChainBuildFailure,
CertificateUtility.X509Certificate2ToString(timestampSignerCertificate))));
}

return timestampCertChain;
}

=======
>>>>>>> Update verify to address spec
private static void ValidateTimestampResponseNonce(
byte[] nonce,
Rfc3161TimestampToken timestampToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,77 +20,7 @@ internal static class Rfc3161TimestampVerificationUtility

#if IS_DESKTOP

<<<<<<< HEAD
/// <summary>
/// Validates a SignedCms object containing a timestamp response.
/// </summary>
/// <param name="timestampCms">SignedCms response from the timestamp authority.</param>
/// <param name="specifications">SigningSpecifications used to validate allowed hash algorithms.</param>
/// <param name="signerCertificate">X509Certificate2 used to sign the data that was timestamped.</param>
/// <param name="data">byte[] data that was signed and timestamped.</param>
public static void Validate(SignedCms timestampCms, SigningSpecifications specifications, X509Certificate2 signerCertificate, byte[] data)
{
if (!ValidateTimestampAlgorithm(timestampCms, specifications))
{
throw new TimestampException(LogMessage.CreateError(
NuGetLogCode.NU3021,
string.Format(CultureInfo.CurrentCulture,
Strings.TimestampResponseExceptionGeneral,
Strings.TimestampFailureInvalidHashAlgorithmOid)));
}

Rfc3161TimestampTokenInfo tstInfo;

if (!TryReadTSTInfoFromSignedCms(timestampCms, out tstInfo))
{
throw new TimestampException(LogMessage.CreateError(
NuGetLogCode.NU3021,
string.Format(CultureInfo.CurrentCulture,
Strings.TimestampResponseExceptionGeneral,
Strings.TimestampFailureInvalidContentType)));
}

if (!ValidateTimestampedData(tstInfo, data))
{
throw new TimestampException(LogMessage.CreateError(
NuGetLogCode.NU3021,
string.Format(CultureInfo.CurrentCulture,
Strings.TimestampResponseExceptionGeneral,
Strings.TimestampFailureInvalidHash)));
}

if (!ValidateSignerCertificateAgainstTimestamp(signerCertificate, tstInfo))
{
throw new TimestampException(LogMessage.CreateError(
NuGetLogCode.NU3012,
Strings.TimestampFailureAuthorCertNotValid));
}

var timestamperCertificate = timestampCms.SignerInfos[0].Certificate;

if (!ValidateTimestampEnhancedKeyUsage(timestamperCertificate))
{
throw new TimestampException(LogMessage.CreateError(
NuGetLogCode.NU3021,
string.Format(CultureInfo.CurrentCulture,
Strings.TimestampResponseExceptionGeneral,
Strings.TimestampFailureCertInvalidEku)));
}

if (!TryBuildTimestampCertificateChain(timestamperCertificate, out var chain))
{
throw new TimestampException(LogMessage.CreateError(
NuGetLogCode.NU3011,
string.Format(CultureInfo.CurrentCulture,
Strings.TimestampCertificateChainBuildFailure,
CertificateUtility.X509Certificate2ToString(timestamperCertificate))));
}
}

private static bool ValidateSignerCertificateAgainstTimestamp(
=======
internal static bool ValidateSignerCertificateAgainstTimestamp(
>>>>>>> Update verify command
X509Certificate2 signerCertificate,
Rfc3161TimestampTokenInfo tstInfo)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public IList<ISignatureVerificationProvider> TrustProviders
_trustProviders = new List<ISignatureVerificationProvider>()
{
new SignatureTrustAndValidityVerificationProvider(),
new IntegrityVerificationProvider(),
new TimestampVerificationProvider()
new IntegrityVerificationProvider()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public IList<ISignatureVerificationProvider> TrustProviders
_trustProviders = new List<ISignatureVerificationProvider>()
{
new SignatureTrustAndValidityVerificationProvider(),
new IntegrityVerificationProvider(),
new TimestampVerificationProvider()
new IntegrityVerificationProvider()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ public async Task RestoreCommand_InvalidSignedPackage()

var signedPackageVerifier = new Mock<IPackageSignatureVerifier>(MockBehavior.Strict);

signedPackageVerifier.Setup(x => x.VerifySignaturesAsync(It.IsAny<ISignedPackageReader>(), It.IsAny<ILogger>(), It.IsAny<CancellationToken>())).
signedPackageVerifier.Setup(x => x.VerifySignaturesAsync(It.IsAny<ISignedPackageReader>(), It.IsAny<CancellationToken>())).
ReturnsAsync(new VerifySignaturesResult(false));

var request = new TestRestoreRequest(spec1, sources, packagesDir.FullName, logger)
Expand Down Expand Up @@ -1057,7 +1057,7 @@ public async Task RestoreCommand_SignedPackage()

var signedPackageVerifier = new Mock<IPackageSignatureVerifier>(MockBehavior.Strict);

signedPackageVerifier.Setup(x => x.VerifySignaturesAsync(It.IsAny<ISignedPackageReader>(), It.IsAny<ILogger>(), It.IsAny<CancellationToken>())).
signedPackageVerifier.Setup(x => x.VerifySignaturesAsync(It.IsAny<ISignedPackageReader>(), It.IsAny<CancellationToken>())).
ReturnsAsync(new VerifySignaturesResult(true));

var request = new TestRestoreRequest(spec1, sources, packagesDir.FullName, logger)
Expand Down

0 comments on commit 37f779d

Please sign in to comment.