Skip to content

Commit 4de00d4

Browse files
authored
Merge pull request #6748 from acmesh-official/dev
sync
2 parents 9e51432 + 40b29c1 commit 4de00d4

File tree

6 files changed

+253
-42
lines changed

6 files changed

+253
-42
lines changed

.github/workflows/DNS.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,4 +597,62 @@ jobs:
597597
598598
599599
600+
Haiku:
601+
runs-on: ubuntu-latest
602+
needs: OpenIndiana
603+
env:
604+
TEST_DNS : ${{ secrets.TEST_DNS }}
605+
TestingDomain: ${{ secrets.TestingDomain }}
606+
TEST_DNS_NO_WILDCARD: ${{ secrets.TEST_DNS_NO_WILDCARD }}
607+
TEST_DNS_NO_SUBDOMAIN: ${{ secrets.TEST_DNS_NO_SUBDOMAIN }}
608+
TEST_DNS_SLEEP: ${{ secrets.TEST_DNS_SLEEP }}
609+
CASE: le_test_dnsapi
610+
TEST_LOCAL: 1
611+
DEBUG: ${{ secrets.DEBUG }}
612+
http_proxy: ${{ secrets.http_proxy }}
613+
https_proxy: ${{ secrets.https_proxy }}
614+
HTTPS_INSECURE: 1 # always set to 1 to ignore https error, since OpenIndiana doesn't accept the expired ISRG X1 root
615+
TokenName1: ${{ secrets.TokenName1}}
616+
TokenName2: ${{ secrets.TokenName2}}
617+
TokenName3: ${{ secrets.TokenName3}}
618+
TokenName4: ${{ secrets.TokenName4}}
619+
TokenName5: ${{ secrets.TokenName5}}
620+
steps:
621+
- uses: actions/checkout@v4
622+
- name: Clone acmetest
623+
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
624+
- uses: vmactions/haiku-vm@v1
625+
with:
626+
envs: 'TEST_DNS TestingDomain TEST_DNS_NO_WILDCARD TEST_DNS_NO_SUBDOMAIN TEST_DNS_SLEEP CASE TEST_LOCAL DEBUG http_proxy https_proxy HTTPS_INSECURE TokenName1 TokenName2 TokenName3 TokenName4 TokenName5 ${{ secrets.TokenName1}} ${{ secrets.TokenName2}} ${{ secrets.TokenName3}} ${{ secrets.TokenName4}} ${{ secrets.TokenName5}}'
627+
sync: rsync
628+
copyback: false
629+
prepare: |
630+
mkdir -p /boot/home/.cache
631+
pkgman install -y cronie
632+
633+
run: |
634+
if [ "${{ secrets.TokenName1}}" ] ; then
635+
export ${{ secrets.TokenName1}}="${{ secrets.TokenValue1}}"
636+
fi
637+
if [ "${{ secrets.TokenName2}}" ] ; then
638+
export ${{ secrets.TokenName2}}="${{ secrets.TokenValue2}}"
639+
fi
640+
if [ "${{ secrets.TokenName3}}" ] ; then
641+
export ${{ secrets.TokenName3}}="${{ secrets.TokenValue3}}"
642+
fi
643+
if [ "${{ secrets.TokenName4}}" ] ; then
644+
export ${{ secrets.TokenName4}}="${{ secrets.TokenValue4}}"
645+
fi
646+
if [ "${{ secrets.TokenName5}}" ] ; then
647+
export ${{ secrets.TokenName5}}="${{ secrets.TokenValue5}}"
648+
fi
649+
cd ../acmetest
650+
./letest.sh
651+
- name: onError
652+
if: ${{ failure() }}
653+
run: |
654+
echo "See how to debug in VM:"
655+
echo "https://github.com/acmesh-official/acme.sh/wiki/debug-in-VM"
656+
657+
600658

.github/workflows/Haiku.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Haiku
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
paths:
7+
- '*.sh'
8+
- '.github/workflows/Haiku.yml'
9+
10+
pull_request:
11+
branches:
12+
- dev
13+
paths:
14+
- '*.sh'
15+
- '.github/workflows/Haiku.yml'
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
22+
23+
jobs:
24+
Haiku:
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
- TEST_ACME_Server: "LetsEncrypt.org_test"
30+
CA_ECDSA: ""
31+
CA: ""
32+
CA_EMAIL: ""
33+
TEST_PREFERRED_CHAIN: (STAGING)
34+
- TEST_ACME_Server: "LetsEncrypt.org_test"
35+
CA_ECDSA: ""
36+
CA: ""
37+
CA_EMAIL: ""
38+
TEST_PREFERRED_CHAIN: (STAGING)
39+
ACME_USE_WGET: 1
40+
#- TEST_ACME_Server: "ZeroSSL.com"
41+
# CA_ECDSA: "ZeroSSL ECC Domain Secure Site CA"
42+
# CA: "ZeroSSL RSA Domain Secure Site CA"
43+
# CA_EMAIL: "githubtest@acme.sh"
44+
# TEST_PREFERRED_CHAIN: ""
45+
runs-on: ubuntu-latest
46+
env:
47+
TEST_LOCAL: 1
48+
TEST_ACME_Server: ${{ matrix.TEST_ACME_Server }}
49+
CA_ECDSA: ${{ matrix.CA_ECDSA }}
50+
CA: ${{ matrix.CA }}
51+
CA_EMAIL: ${{ matrix.CA_EMAIL }}
52+
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
53+
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: vmactions/cf-tunnel@v0
57+
id: tunnel
58+
with:
59+
protocol: http
60+
port: 8080
61+
- name: Set envs
62+
run: echo "TestingDomain=${{steps.tunnel.outputs.server}}" >> $GITHUB_ENV
63+
- name: Clone acmetest
64+
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
65+
- uses: vmactions/haiku-vm@v1
66+
with:
67+
envs: 'TEST_LOCAL TestingDomain TEST_ACME_Server CA_ECDSA CA CA_EMAIL TEST_PREFERRED_CHAIN ACME_USE_WGET'
68+
nat: |
69+
"8080": "80"
70+
prepare: |
71+
mkdir -p /boot/home/.cache
72+
pkgman install -y cronie
73+
sync: rsync
74+
copyback: false
75+
run: |
76+
cd ../acmetest \
77+
&& ./letest.sh
78+
- name: onError
79+
if: ${{ failure() }}
80+
run: |
81+
echo "See how to debug in VM:"
82+
echo "https://github.com/acmesh-official/acme.sh/wiki/debug-in-VM"
83+

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<a href="https://github.com/acmesh-official/acme.sh/actions/workflows/DragonFlyBSD.yml"><img src="https://github.com/acmesh-official/acme.sh/actions/workflows/DragonFlyBSD.yml/badge.svg" alt="DragonFlyBSD"></a>
1919
<a href="https://github.com/acmesh-official/acme.sh/actions/workflows/Omnios.yml"><img src="https://github.com/acmesh-official/acme.sh/actions/workflows/Omnios.yml/badge.svg" alt="Omnios"></a>
2020
<a href="https://github.com/acmesh-official/acme.sh/actions/workflows/OpenIndiana.yml"><img src="https://github.com/acmesh-official/acme.sh/actions/workflows/OpenIndiana.yml/badge.svg" alt="OpenIndiana"></a>
21+
<a href="https://github.com/acmesh-official/acme.sh/actions/workflows/Haiku.yml"><img src="https://github.com/acmesh-official/acme.sh/actions/workflows/Haiku.yml/badge.svg" alt="Haiku"></a>
2122
</p>
2223

2324
<p align="center">
@@ -108,6 +109,7 @@
108109
|21|-----| Cloud Linux https://github.com/acmesh-official/acme.sh/issues/111
109110
|22|-----| OpenWRT: Tested and working. See [wiki page](https://github.com/acmesh-official/acme.sh/wiki/How-to-run-on-OpenWRT)
110111
|23|[![](https://acmesh-official.github.io/acmetest/status/proxmox.svg)](https://github.com/acmesh-official/letest#here-are-the-latest-status)| Proxmox: See Proxmox VE Wiki. Version [4.x, 5.0, 5.1](https://pve.proxmox.com/wiki/HTTPS_Certificate_Configuration_(Version_4.x,_5.0_and_5.1)#Let.27s_Encrypt_using_acme.sh), version [5.2 and up](https://pve.proxmox.com/wiki/Certificate_Management)
112+
|24|[![Haiku](https://github.com/acmesh-official/acme.sh/actions/workflows/Haiku.yml/badge.svg)](https://github.com/acmesh-official/acme.sh/actions/workflows/Haiku.yml)|Haiku OS
111113

112114

113115
> 🧪 Check our [testing project](https://github.com/acmesh-official/acmetest)

acme.sh

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ _dlg_versions() {
250250
socat -V 2>&1
251251
else
252252
_debug "socat doesn't exist."
253+
if _exists "python3"; then
254+
python3 -V 2>&1
255+
elif _exists "python2"; then
256+
python2 -V 2>&1
257+
elif _exists "python"; then
258+
python -V 2>&1
259+
fi
253260
fi
254261
}
255262

@@ -2559,41 +2566,76 @@ _startserver() {
25592566
_debug Le_Listen_V4 "$Le_Listen_V4"
25602567
_debug Le_Listen_V6 "$Le_Listen_V6"
25612568

2562-
_NC="socat"
2563-
if [ "$Le_Listen_V6" ]; then
2564-
_NC="$_NC -6"
2565-
SOCAT_OPTIONS=TCP6-LISTEN
2566-
elif [ "$Le_Listen_V4" ]; then
2567-
_NC="$_NC -4"
2568-
SOCAT_OPTIONS=TCP4-LISTEN
2569-
else
2570-
SOCAT_OPTIONS=TCP-LISTEN
2571-
fi
2569+
if _exists "socat"; then
2570+
_NC="socat"
2571+
if [ "$Le_Listen_V6" ]; then
2572+
_NC="$_NC -6"
2573+
SOCAT_OPTIONS=TCP6-LISTEN
2574+
elif [ "$Le_Listen_V4" ]; then
2575+
_NC="$_NC -4"
2576+
SOCAT_OPTIONS=TCP4-LISTEN
2577+
else
2578+
SOCAT_OPTIONS=TCP-LISTEN
2579+
fi
25722580

2573-
if [ "$DEBUG" ] && [ "$DEBUG" -gt "1" ]; then
2574-
_NC="$_NC -d -d -v"
2575-
fi
2581+
if [ "$DEBUG" ] && [ "$DEBUG" -gt "1" ]; then
2582+
_NC="$_NC -d -d -v"
2583+
fi
25762584

2577-
SOCAT_OPTIONS=$SOCAT_OPTIONS:$Le_HTTPPort,crlf,reuseaddr,fork
2585+
SOCAT_OPTIONS=$SOCAT_OPTIONS:$Le_HTTPPort,crlf,reuseaddr,fork
25782586

2579-
#Adding bind to local-address
2580-
if [ "$ncaddr" ]; then
2581-
SOCAT_OPTIONS="$SOCAT_OPTIONS,bind=${ncaddr}"
2582-
fi
2587+
#Adding bind to local-address
2588+
if [ "$ncaddr" ]; then
2589+
SOCAT_OPTIONS="$SOCAT_OPTIONS,bind=${ncaddr}"
2590+
fi
25832591

2584-
_content_len="$(printf "%s" "$content" | wc -c)"
2585-
_debug _content_len "$_content_len"
2586-
_debug "_NC" "$_NC $SOCAT_OPTIONS"
2587-
export _SOCAT_ERR="$(_mktemp)"
2588-
$_NC $SOCAT_OPTIONS SYSTEM:"sleep 1; \
2592+
_content_len="$(printf "%s" "$content" | wc -c)"
2593+
_debug _content_len "$_content_len"
2594+
_debug "_NC" "$_NC $SOCAT_OPTIONS"
2595+
export _SOCAT_ERR="$(_mktemp)"
2596+
$_NC $SOCAT_OPTIONS SYSTEM:"sleep 1; \
25892597
echo 'HTTP/1.0 200 OK'; \
25902598
echo 'Content-Length\: $_content_len'; \
25912599
echo ''; \
25922600
printf '%s' '$content';" 2>"$_SOCAT_ERR" &
2593-
serverproc="$!"
2601+
serverproc="$!"
2602+
else
2603+
_PYTHON=""
2604+
if _exists "python3"; then
2605+
_PYTHON="python3"
2606+
elif _exists "python2"; then
2607+
_PYTHON="python2"
2608+
elif _exists "python"; then
2609+
_PYTHON="python"
2610+
fi
2611+
if [ "$_PYTHON" ]; then
2612+
_debug "Using python: $_PYTHON"
2613+
_AF="socket.AF_INET"
2614+
_BIND_ADDR="0.0.0.0"
2615+
if [ "$Le_Listen_V6" ]; then
2616+
_AF="socket.AF_INET6"
2617+
_BIND_ADDR="::"
2618+
fi
2619+
if [ "$ncaddr" ]; then
2620+
_BIND_ADDR="$ncaddr"
2621+
fi
2622+
export _SOCAT_ERR="$(_mktemp)"
2623+
$_PYTHON -c "import socket,sys;s=socket.socket($_AF,socket.SOCK_STREAM);s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1);s.bind((sys.argv[2],int(sys.argv[1])));s.listen(5);res='HTTP/1.0 200 OK\r\nContent-Length: '+str(len(sys.argv[3]))+'\r\n\r\n'+sys.argv[3];
2624+
while True:
2625+
c,a=s.accept()
2626+
c.sendall(res.encode() if hasattr(res, 'encode') else res)
2627+
c.close()" "$Le_HTTPPort" "$_BIND_ADDR" "$content" 2>"$_SOCAT_ERR" &
2628+
serverproc="$!"
2629+
_NC="$_PYTHON"
2630+
else
2631+
_err "Please install socat or python first for standalone mode."
2632+
return 1
2633+
fi
2634+
fi
2635+
25942636
if [ -f "$_SOCAT_ERR" ]; then
25952637
if grep "Permission denied" "$_SOCAT_ERR" >/dev/null; then
2596-
_err "socat: $(cat $_SOCAT_ERR)"
2638+
_err "$_NC: $(cat $_SOCAT_ERR)"
25972639
_err "Can not listen for user: $(whoami)"
25982640
_err "Maybe try with root again?"
25992641
rm -f "$_SOCAT_ERR"
@@ -3557,9 +3599,9 @@ _on_before_issue() {
35573599
fi
35583600
fi
35593601

3560-
if _hasfield "$_chk_web_roots" "$NO_VALUE"; then
3561-
if ! _exists "socat"; then
3562-
_err "Please install socat tools first."
3602+
if _hasfield "$_chk_web_roots" "$NO_VALUE" && [ "$_chk_web_roots" = "$NO_VALUE" ]; then
3603+
if ! _exists "socat" && ! _exists "python" && ! _exists "python2" && ! _exists "python3"; then
3604+
_err "Please install socat or python tools first."
35633605
return 1
35643606
fi
35653607
fi
@@ -6664,9 +6706,9 @@ _precheck() {
66646706
return 1
66656707
fi
66666708

6667-
if ! _exists "socat"; then
6668-
_err "It is recommended to install socat first."
6669-
_err "We use socat for the standalone server, which is used for standalone mode."
6709+
if ! _exists "socat" && ! _exists "python" && ! _exists "python2" && ! _exists "python3"; then
6710+
_err "It is recommended to install socat or python first."
6711+
_err "We use socat or python for the standalone server, which is used for standalone mode."
66706712
_err "If you don't want to use standalone mode, you may ignore this warning."
66716713
fi
66726714

dnsapi/dns_cyon.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ _cyon_load_parameters() {
101101
# This header is required for curl calls.
102102
_H1="X-Requested-With: XMLHttpRequest"
103103
export _H1
104+
_H3="User-Agent: cyon-dns-acmesh/1.0"
105+
export _H3
104106
}
105107

106108
_cyon_print_header() {
@@ -125,7 +127,11 @@ _cyon_print_header() {
125127
}
126128

127129
_cyon_get_cookie_header() {
128-
printf "Cookie: %s" "$(grep "cyon=" "$HTTP_HEADER" | grep "^Set-Cookie:" | _tail_n 1 | _egrep_o 'cyon=[^;]*;' | tr -d ';')"
130+
# Extract all cookies from the response headers (case-insensitive)
131+
_cookies="$(grep -i "^set-cookie:" "$HTTP_HEADER" | sed 's/^[Ss]et-[Cc]ookie: //' | sed 's/;.*//' | tr '\n' '; ' | sed 's/; $//')"
132+
if [ -n "$_cookies" ]; then
133+
printf "Cookie: %s" "$_cookies"
134+
fi
129135
}
130136

131137
_cyon_login() {
@@ -155,7 +161,12 @@ _cyon_login() {
155161

156162
_get "https://my.cyon.ch/" >/dev/null
157163

158-
# todo: instead of just checking if the env variable is defined, check if we actually need to do a 2FA auth request.
164+
# Update cookie after loading main page (only if new cookies are set)
165+
_new_cookies="$(_cyon_get_cookie_header)"
166+
if [ -n "$_new_cookies" ]; then
167+
_H2="$_new_cookies"
168+
export _H2
169+
fi
159170

160171
# 2FA authentication with OTP?
161172
if [ -n "${CY_OTP_Secret}" ]; then
@@ -184,6 +195,13 @@ _cyon_login() {
184195
fi
185196

186197
_info " success"
198+
199+
# Update cookie after 2FA (only if new cookies are set)
200+
_new_cookies="$(_cyon_get_cookie_header)"
201+
if [ -n "$_new_cookies" ]; then
202+
_H2="$_new_cookies"
203+
export _H2
204+
fi
187205
fi
188206

189207
_info ""
@@ -205,7 +223,17 @@ _cyon_change_domain_env() {
205223
domain_env="$(printf "%s" "${fulldomain}" | sed -E -e 's/.*\.(.*\..*)$/\1/')"
206224
_debug "Changing domain environment to ${domain_env}"
207225

208-
gloo_item_key="$(_get "https://my.cyon.ch/domain/" | tr '\n' ' ' | sed -E -e "s/.*data-domain=\"${domain_env}\"[^<]*data-itemkey=\"([^\"]*).*/\1/")"
226+
domain_page_response="$(_get "https://my.cyon.ch/domain/")"
227+
_debug domain_page_response "${domain_page_response}"
228+
229+
# Check if we got an error response (JSON) instead of HTML
230+
if printf "%s" "${domain_page_response}" | grep -q '"iserror":true'; then
231+
_err " $(printf "%s" "${domain_page_response}" | _cyon_get_response_message)"
232+
_err ""
233+
return 1
234+
fi
235+
236+
gloo_item_key="$(printf "%s" "${domain_page_response}" | tr '\n' ' ' | sed -E -e "s/.*data-domain=\"${domain_env}\"[^<]*data-itemkey=\"([^\"]*).*/\1/")"
209237
_debug gloo_item_key "${gloo_item_key}"
210238

211239
domain_env_url="https://my.cyon.ch/user/environment/setdomain/d/${domain_env}/gik/${gloo_item_key}"

0 commit comments

Comments
 (0)