Skip to content

Instantly share code, notes, and snippets.

@makah
Created October 21, 2016 02:21
Show Gist options
  • Save makah/acbf3782d8f2f94fd2da9d52458b8bba to your computer and use it in GitHub Desktop.
Save makah/acbf3782d8f2f94fd2da9d52458b8bba to your computer and use it in GitHub Desktop.
public IRegistryService Connect(String name, RSACryptoServiceProvider privateKey, X509Certificate2 acsCertificate) {
if ((String.IsNullOrEmpty(name)) || (acsCertificate == null) ||
(privateKey == null))
throw new ArgumentException("....");
if (!String.IsNullOrEmpty(this.Credential.identifier))
throw new ACSLoginFailureException("....");
byte[] challenge = this.acs.getChallenge(name);
byte[] answer = new byte[0];
try {
answer = Crypto.GenerateAnswer(challenge, privateKey, acsCertificate);
}
catch (CryptographicException e) {
throw new ACSLoginFailureException("....", e);
}
bool connect = this.acs.loginByCertificate(name, answer, out this.credential, out leaseTime);
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment