pub enum SecurityPolicy {
Basic256Sha256,
Aes128Sha256RsaOaep,
Aes256Sha256RsaPss,
}Expand description
Security policy for a SignAndEncrypt secure channel.
Variants§
Basic256Sha256
Widely supported RSA policy.
Aes128Sha256RsaOaep
RSA-OAEP key exchange with AES-128 symmetric encryption.
Aes256Sha256RsaPss
RSA-PSS signatures with AES-256 symmetric encryption.
Implementations§
Source§impl SecurityPolicy
impl SecurityPolicy
Sourcepub const fn uri(self) -> &'static str
pub const fn uri(self) -> &'static str
OPC UA policy URI for endpoint selection.
Examples found in repository?
examples/local_server.rs (line 41)
15fn main() -> Result<(), Box<dyn Error>> {
16 let port = std::env::args()
17 .nth(1)
18 .unwrap_or_else(|| "4840".into())
19 .parse::<NonZeroU16>()?;
20 let args: Vec<String> = std::env::args().skip(2).collect();
21 let (host, runner) = match args.as_slice() {
22 [] => Server::loopback(port, "urn:example:line")?,
23 [uri, cert, key, client_uri, client_cert, policy @ ..] => Server::secure_with_policy(
24 SecureServerConfig {
25 bind: ([127, 0, 0, 1], port.get()).into(),
26 application_uri: uri,
27 certificate_der: &std::fs::read(cert)?,
28 private_key_der: &std::fs::read(key)?,
29 trusted_client_uri: client_uri,
30 trusted_client_certificate_der: &std::fs::read(client_cert)?,
31 },
32 "urn:example:line",
33 match policy {
34 [] => SecurityPolicy::Basic256Sha256,
35 [p] => [
36 SecurityPolicy::Basic256Sha256,
37 SecurityPolicy::Aes128Sha256RsaOaep,
38 SecurityPolicy::Aes256Sha256RsaPss,
39 ]
40 .into_iter()
41 .find(|policy| policy.uri().rsplit('#').next() == Some(p.as_str()))
42 .ok_or("unknown security policy")?,
43 _ => return Err("expected at most one security policy".into()),
44 },
45 )?,
46 _ => {
47 return Err(
48 "expected PORT [SERVER_URI SERVER.der SERVER_KEY.der CLIENT_URI CLIENT.der [POLICY]]".into(),
49 );
50 }
51 };
52 let counter = host.add_variable("PartsProduced", 0_u64)?;
53 let stop = Arc::new(AtomicBool::new(false));
54 let input_closed = Arc::clone(&stop);
55 thread::spawn(move || {
56 for line in io::stdin().lock().lines() {
57 let Ok(line) = line else { break };
58 match line.trim().parse() {
59 Ok(n) => {
60 if let Err(error) = counter.set(n) {
61 eprintln!("update failed: {error}");
62 }
63 }
64 Err(error) => eprintln!("expected a UInt64: {error}"),
65 }
66 }
67 input_closed.store(true, Ordering::Release);
68 });
69 eprintln!("Serving PartsProduced on opc.tcp://127.0.0.1:{port} while stdin is open");
70 runner.run_until(|| stop.load(Ordering::Acquire))?;
71 Ok(())
72}Trait Implementations§
Source§impl Clone for SecurityPolicy
impl Clone for SecurityPolicy
impl Copy for SecurityPolicy
Source§impl Debug for SecurityPolicy
impl Debug for SecurityPolicy
Source§impl Default for SecurityPolicy
impl Default for SecurityPolicy
impl Eq for SecurityPolicy
Source§impl PartialEq for SecurityPolicy
impl PartialEq for SecurityPolicy
impl StructuralPartialEq for SecurityPolicy
Auto Trait Implementations§
impl Forget for SecurityPolicy
impl Freeze for SecurityPolicy
impl Move for SecurityPolicy
impl RefUnwindSafe for SecurityPolicy
impl Send for SecurityPolicy
impl Sync for SecurityPolicy
impl Unpin for SecurityPolicy
impl UnsafeUnpin for SecurityPolicy
impl UnwindSafe for SecurityPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more