Struct cryptographic_message_syntax::asn1::rfc3161::TimeStampResp
source · pub struct TimeStampResp {
pub status: PkiStatusInfo,
pub time_stamp_token: Option<TimeStampToken>,
}Expand description
Time stamp response.
TimeStampResp ::= SEQUENCE {
status PKIStatusInfo,
timeStampToken TimeStampToken OPTIONAL }
Fields§
§status: PkiStatusInfo§time_stamp_token: Option<TimeStampToken>Implementations§
source§impl TimeStampResp
impl TimeStampResp
sourcepub fn take_from<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<Self, DecodeError<S::Error>>
pub fn take_from<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<Self, DecodeError<S::Error>>
Examples found in repository?
src/time_stamp_protocol.rs (line 178)
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
pub fn time_stamp_request_http(
url: impl IntoUrl,
request: &TimeStampReq,
) -> Result<TimeStampResponse, TimeStampError> {
let client = reqwest::blocking::Client::new();
let mut body = Vec::<u8>::new();
request
.encode_ref()
.write_encoded(bcder::Mode::Der, &mut body)?;
let response = client
.post(url)
.header("Content-Type", HTTP_CONTENT_TYPE_REQUEST)
.body(body)
.send()?;
if response.status().is_success()
&& response.headers().get("Content-Type")
== Some(&reqwest::header::HeaderValue::from_static(
HTTP_CONTENT_TYPE_RESPONSE,
))
{
let response_bytes = response.bytes()?;
let res = TimeStampResponse(Constructed::decode(
response_bytes.as_ref(),
bcder::Mode::Der,
|cons| TimeStampResp::take_from(cons),
)?);
// Verify nonce was reflected, if present.
if res.is_success() {
if let Some(tst_info) = res.tst_info()? {
if tst_info.nonce != request.nonce {
return Err(TimeStampError::NonceMismatch);
}
}
}
Ok(res)
} else {
Err(TimeStampError::Http("bad HTTP response"))
}
}pub fn encode_ref(&self) -> impl Values + '_
Trait Implementations§
source§impl Clone for TimeStampResp
impl Clone for TimeStampResp
source§fn clone(&self) -> TimeStampResp
fn clone(&self) -> TimeStampResp
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for TimeStampResp
impl Debug for TimeStampResp
source§impl PartialEq<TimeStampResp> for TimeStampResp
impl PartialEq<TimeStampResp> for TimeStampResp
source§fn eq(&self, other: &TimeStampResp) -> bool
fn eq(&self, other: &TimeStampResp) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for TimeStampResp
impl StructuralEq for TimeStampResp
impl StructuralPartialEq for TimeStampResp
Auto Trait Implementations§
impl RefUnwindSafe for TimeStampResp
impl Send for TimeStampResp
impl Sync for TimeStampResp
impl Unpin for TimeStampResp
impl UnwindSafe for TimeStampResp
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.