public string CreateSignedPacket(string uri, bool shuttingDown) { if (!IsServerInfo) { throw new InvalidOperationException("Cannot generate packets from non-server instances"); } string jsonPart = GetAnnounceJson(uri, shuttingDown); var rsa = (RSACryptoServiceProvider)Certificate.PrivateKey; return( jsonPart + "\n\n" + CryptoUtils.CertificateToPEM(Certificate) + "\n" + CryptoUtils.Base64Folded(null, rsa.SignData(Encoding.UTF8.GetBytes(jsonPart), "SHA256"), 76) + "\n"); }