/// <summary>Get timestamp token - communications layer</summary> /// <returns>- byte[] - TSA response, raw bytes (RFC 3161 encoded)</returns> /// <exception cref="System.IO.IOException"/> protected internal virtual byte[] GetTSAResponse(byte[] requestBytes) { // Setup the TSA connection SignUtils.TsaResponse response = SignUtils.GetTsaResponseForUserRequest(tsaURL, requestBytes, tsaUsername, tsaPassword); // Get TSA response as a byte array Stream inp = response.tsaResponseStream; MemoryStream baos = new MemoryStream(); byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = inp.JRead(buffer, 0, buffer.Length)) >= 0) { baos.Write(buffer, 0, bytesRead); } byte[] respBytes = baos.ToArray(); if (response.encoding != null && response.encoding.ToLower(System.Globalization.CultureInfo.InvariantCulture ).Equals("base64".ToLower(System.Globalization.CultureInfo.InvariantCulture))) { respBytes = System.Convert.FromBase64String(iText.IO.Util.JavaUtil.GetStringForBytes(respBytes, "US-ASCII" )); } return(respBytes); }