Skip to content

Commit

Permalink
poem 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Mar 30, 2024
1 parent cba2ecb commit 371baa8
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 59 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ repository = "https://github.com/poem-web/poem"
rust-version = "1.75"

[workspace.dependencies]
poem = { path = "poem", version = "2.0.1", default-features = false }
poem-derive = { path = "poem-derive", version = "2.0.1" }
poem-openapi-derive = { path = "poem-openapi-derive", version = "4.0.1" }
poem-grpc-build = { path = "poem-grpc-build", version = "0.3.0" }
poem = { path = "poem", version = "3.0.0", default-features = false }
poem-derive = { path = "poem-derive", version = "3.0.0" }
poem-openapi-derive = { path = "poem-openapi-derive", version = "5.0.0" }
poem-grpc-build = { path = "poem-grpc-build", version = "0.4.0" }

proc-macro-crate = "3.0.0"
proc-macro2 = "1.0.29"
Expand All @@ -42,7 +42,7 @@ futures-util = "0.3.17"
tokio-stream = "0.1.8"
serde_yaml = "0.9"
quick-xml = { version = "0.31.0", features = ["serialize"] }
base64 = "0.21.0"
base64 = "0.22.0"
serde_urlencoded = "0.7.1"
indexmap = "2.0.0"
reqwest = { version = "0.12.2", default-features = false }
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion poem-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem-derive"
version = "2.0.1"
version = "3.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion poem-grpc-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem-grpc-build"
version = "0.3.0"
version = "0.4.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions poem-grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem-grpc"
version = "0.3.0"
version = "0.4.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down Expand Up @@ -28,7 +28,7 @@ itoa = "1.0.2"
percent-encoding = "2.1.0"
bytes.workspace = true
prost = "0.12.0"
base64 = "0.21.0"
base64.workspace = true
prost-types = "0.12.0"
tokio-stream = { workspace = true, features = ["sync"] }
serde = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion poem-lambda/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [5.0.0] 2024-03-24
# [5.0.0] 2024-03-30

- use AFIT instead of `async_trait`
- Bump `lambda_http` from `0.9` to `0.10`
Expand Down
4 changes: 2 additions & 2 deletions poem-lambda/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem-lambda"
version = "4.0.0"
version = "5.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand All @@ -21,7 +21,7 @@ categories = [
[dependencies]
poem = { workspace = true, default-features = false }

lambda_http = { version = "0.10.0" }
lambda_http = { version = "0.11.0" }

[dev-dependencies]
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
2 changes: 1 addition & 1 deletion poem-openapi-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem-openapi-derive"
version = "4.0.1"
version = "5.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [5.0.0] 2024-03-24
# [5.0.0] 2024-03-30

- use AFIT instead of `async_trait`
- add `Upload::size` method
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem-openapi"
version = "4.0.1"
version = "5.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
17 changes: 10 additions & 7 deletions poem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [3.0.0] 2024-03-24
# [3.0.0] 2024-03-30

- use AFIT instead of `async_trait`
- bump `priority-queue` to 2.0
- bump `x509-parser` to 0.16
- bump `nix` to 0.28
- bump `redis` to 0.25
- bump `reqwest` to 0.12
- bump `opentelemetry` to 0.22 [#784](https://github.com/poem-web/poem/pull/784)
- bump `priority-queue` to `2.0`
- bump `x509-parser` to `0.16`
- bump `nix` to `0.28`
- bump `redis` to `0.25`
- bump `reqwest` to `0.12`
- bump `opentelemetry` to `0.22` [#784](https://github.com/poem-web/poem/pull/784)
- bump `sync_wrapper` to `1.0.0`
- bump `rcgen ` to `0.13.0`
- bump `base64 ` to `0.22.0`

# [2.0.1] 2024-03-04

Expand Down
6 changes: 3 additions & 3 deletions poem/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem"
version = "2.0.1"
version = "3.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down Expand Up @@ -92,7 +92,7 @@ thiserror.workspace = true
rfc7239 = "0.1.0"
mime.workspace = true
wildmatch = "2"
sync_wrapper = { version = "0.1.2", features = ["futures"] }
sync_wrapper = { version = "1.0.0", features = ["futures"] }

# Non-feature optional dependencies
multer = { version = "3.0.0", features = ["tokio"], optional = true }
Expand Down Expand Up @@ -150,7 +150,7 @@ unic-langid = { version = "0.9.0", optional = true, features = ["macros"] }
intl-memoizer = { version = "0.5.1", optional = true }
ring = { version = "0.17.7", optional = true }
reqwest = { workspace = true, features = ["json"], optional = true }
rcgen = { version = "0.12.0", optional = true }
rcgen = { version = "0.13.0", optional = true }
x509-parser = { version = "0.16.0", optional = true }
tokio-metrics = { version = "0.3.0", optional = true }
rust-embed = { version = "8.0", optional = true }
Expand Down
58 changes: 24 additions & 34 deletions poem/src/listener/acme/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use std::{
};

use http::uri::Scheme;
use rcgen::{
Certificate, CertificateParams, CustomExtension, DistinguishedName, PKCS_ECDSA_P256_SHA256,
};
use rcgen::{CertificateParams, CustomExtension, KeyPair, PKCS_ECDSA_P256_SHA256};
use tokio_rustls::{
rustls::{
crypto::ring::sign::any_ecdsa_type,
Expand Down Expand Up @@ -229,21 +227,21 @@ impl<T: Acceptor> Acceptor for AutoCertAcceptor<T> {
}

fn gen_acme_cert(domain: &str, acme_hash: &[u8]) -> IoResult<CertifiedKey> {
let mut params = CertificateParams::new(vec![domain.to_string()]);
params.alg = &PKCS_ECDSA_P256_SHA256;
params.custom_extensions = vec![CustomExtension::new_acme_identifier(acme_hash)];
let cert = Certificate::from_params(params)
.map_err(|_| IoError::new(ErrorKind::Other, "failed to generate acme certificate"))?;
let key = any_ecdsa_type(&PrivateKeyDer::Pkcs8(
cert.serialize_private_key_der().into(),
))
.unwrap();
Ok(CertifiedKey::new(
vec![CertificateDer::from(cert.serialize_der().map_err(
|_| IoError::new(ErrorKind::Other, "failed to serialize acme certificate"),
)?)],
key,
))
let keypair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256).expect("create key pair");
let cert = CertificateParams::new(vec![domain.to_string()])
.and_then(|mut params| {
params.custom_extensions = vec![CustomExtension::new_acme_identifier(acme_hash)];
params.self_signed(&keypair)
})
.map_err(|err| {
IoError::new(
ErrorKind::Other,
format!("failed to generate acme certificate: {err}"),
)
})?;

let key = any_ecdsa_type(&PrivateKeyDer::Pkcs8(keypair.serialized_der().into())).unwrap();
Ok(CertifiedKey::new(vec![cert.der().clone()], key))
}

/// The result of [`issue_cert`] function.
Expand Down Expand Up @@ -343,31 +341,23 @@ pub async fn issue_cert<T: AsRef<str>>(
}

// send csr
let mut params = CertificateParams::new(
let keypair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256).expect("create key pair");
let request = CertificateParams::new(
domains
.iter()
.map(|domain| domain.as_ref().to_string())
.collect::<Vec<_>>(),
);
params.distinguished_name = DistinguishedName::new();
params.alg = &PKCS_ECDSA_P256_SHA256;
let cert = Certificate::from_params(params).map_err(|err| {
)
.and_then(|params| params.serialize_request(&keypair))
.map_err(|err| {
IoError::new(
ErrorKind::Other,
format!("failed create certificate request: {err}"),
)
})?;
let pk = any_ecdsa_type(&PrivateKeyDer::Pkcs8(
cert.serialize_private_key_der().into(),
))
.unwrap();
let csr = cert.serialize_request_der().map_err(|err| {
IoError::new(
ErrorKind::Other,
format!("failed to serialize request der {err}"),
)
})?;

let pk = any_ecdsa_type(&PrivateKeyDer::Pkcs8(keypair.serialized_der().into())).unwrap();
let csr = request.der().as_ref();
let order_resp = client.send_csr(&order_resp.finalize, &csr).await?;

if order_resp.status == "invalid" {
Expand Down Expand Up @@ -403,7 +393,7 @@ pub async fn issue_cert<T: AsRef<str>>(
)
})?)
.await?;
let pkey_pem = cert.serialize_private_key_pem();
let pkey_pem = keypair.serialize_pem();
let cert_chain = rustls_pemfile::certs(&mut acme_cert_pem.as_slice())
.collect::<Result<_, _>>()
.map_err(|err| IoError::new(ErrorKind::Other, format!("invalid pem: {err}")))?;
Expand Down

0 comments on commit 371baa8

Please sign in to comment.