Compare commits
10
Commits
811c904fef
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f0c522fc3 | ||
|
|
7d1c10be09 | ||
|
|
f9d2b7f747 | ||
|
|
b8a198f5ee | ||
|
|
b1937cca19 | ||
|
|
a0ec20bdc2 | ||
|
|
2d1a456442 | ||
|
|
b2daec01d2 | ||
|
|
ed3aa2cccb | ||
|
|
114e2c2c9d |
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
cert
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
name: Docker
|
||||||
|
|
||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '23 17 * * *'
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
# Publish semver tags as releases.
|
||||||
|
tags: [ 'v*.*.*' ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Use docker.io for Docker Hub if empty
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
# github.repository as <account>/<repo>
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
# This is used to complete the identity challenge
|
||||||
|
# with sigstore/fulcio when running outside of PRs.
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Install the cosign tool except on PR
|
||||||
|
# https://github.com/sigstore/cosign-installer
|
||||||
|
- name: Install Cosign
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: sigstore/cosign-installer@v3.5.0
|
||||||
|
|
||||||
|
# Set up BuildKit Docker container builder to be able to build
|
||||||
|
# multi-platform images and export cache
|
||||||
|
# https://github.com/docker/setup-buildx-action
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||||
|
|
||||||
|
# Login against a Docker registry except on PR
|
||||||
|
# https://github.com/docker/login-action
|
||||||
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Extract metadata (tags, labels) for Docker
|
||||||
|
# https://github.com/docker/metadata-action
|
||||||
|
- name: Extract Docker metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
# Build and push Docker image with Buildx (don't push on PR)
|
||||||
|
# https://github.com/docker/build-push-action
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: build-and-push
|
||||||
|
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
# Sign the resulting Docker image digest except on PRs.
|
||||||
|
# This will only write to the public Rekor transparency log when the Docker
|
||||||
|
# repository is public to avoid leaking data. If you would like to publish
|
||||||
|
# transparency data even for private images, pass --force to cosign below.
|
||||||
|
# https://github.com/sigstore/cosign
|
||||||
|
- name: Sign the published Docker image
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
env:
|
||||||
|
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
|
||||||
|
TAGS: ${{ steps.meta.outputs.tags }}
|
||||||
|
DIGEST: ${{ steps.build-and-push.outputs.digest }}
|
||||||
|
# This step uses the identity token to provision an ephemeral certificate
|
||||||
|
# against the sigstore community Fulcio instance.
|
||||||
|
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
cert
|
||||||
+32
-4
@@ -1,7 +1,35 @@
|
|||||||
FROM ubuntu:latest
|
#FROM ubuntu:latest
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y git unzip sudo wget build-essential pkg-config
|
#RUN apt-get update && apt-get install -y git unzip sudo wget build-essential pkg-config python3 python3-pip
|
||||||
RUN git clone https://github.com/kov-serg/get-cpcert.git && cd get-cpcert && chmod +x *.sh
|
#RUN git clone https://github.com/kov-serg/get-cpcert.git && cd get-cpcert && chmod +x *.sh
|
||||||
RUN cd /get-cpcert/ && ./prepare.sh
|
#RUN cd /get-cpcert/ && ./prepare.sh
|
||||||
|
|
||||||
|
FROM debian
|
||||||
|
RUN apt-get update && apt-get install -y libengine-gost-openssl openssl nano mc git unzip sudo wget build-essential pkg-config python3 python3-pip
|
||||||
|
|
||||||
|
ARG PREFIX="/etc/ssl"
|
||||||
|
ARG ENGINES=/usr/lib/x86_64-linux-gnu/engines-3
|
||||||
|
|
||||||
|
# Enable engine
|
||||||
|
RUN sed -i '6i openssl_conf=openssl_def' ${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "# OpenSSL default section" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "[openssl_def]" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "engines = engine_section" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "# Engine scetion" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "[engine_section]" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "gost = gost_section" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "" >> ${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "# Engine gost section" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "[gost_section]" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "engine_id = gost" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "dynamic_path = ${ENGINES}/gost.so" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "default_algorithms = ALL" >>${PREFIX}/openssl.cnf \
|
||||||
|
&& echo "CRYPT_PARAMS = id-Gost28147-89-CryptoPro-A-ParamSet" >>${PREFIX}/openssl.cnf
|
||||||
|
|
||||||
|
|
||||||
|
ADD ./src /src
|
||||||
|
RUN pip install -r /src/requirements.txt --break-system-packages
|
||||||
|
|
||||||
ENTRYPOINT ["bash"]
|
ENTRYPOINT ["bash"]
|
||||||
@@ -30,5 +30,17 @@ https://habr.com/ru/post/550664/
|
|||||||
```
|
```
|
||||||
openssl pkcs12 -in auth.p12 -out key.pem -engine gost -nodes -clcerts
|
openssl pkcs12 -in auth.p12 -out key.pem -engine gost -nodes -clcerts
|
||||||
openssl pkcs12 -in auth.p12 -clcerts -nokeys -out pub.crt
|
openssl pkcs12 -in auth.p12 -clcerts -nokeys -out pub.crt
|
||||||
openssl smime -sign -signer pub.crt -inkey key.pem -engine gost -binary -noattr -outform DER -in document.pdf -out document.pdf.sig
|
openssl smime -sign -signer pub.crt -inkey key.pem -engine gost -binary -outform DER -in document.pdf -out document.pdf.sig
|
||||||
```
|
```
|
||||||
|
or
|
||||||
|
```
|
||||||
|
openssl cms -sign -engine gost -inkey key.pem -signer pub.crt -in document.xml -binary -outform DER -out document.xml.sgn
|
||||||
|
```
|
||||||
|
or with cades support
|
||||||
|
```
|
||||||
|
openssl cms -sign -engine gost -inkey key.pem -cades -nosmimecap -signer pub.crt -in document.xml -binary -outform DER -out document.xml.sgn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Если вы получаете ошибку про 1.2.840.113549.1.12.1.80
|
||||||
|
Используйте этот образ на скопированном из криптопро ключе. На криптопро 5 работает.
|
||||||
|
https://github.com/s-sokolko/export-cryptopro-cert-docker
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
#!flask/bin/python
|
||||||
|
import tempfile
|
||||||
|
import os.path
|
||||||
|
import base64
|
||||||
|
import logging
|
||||||
|
from flask import Flask, jsonify
|
||||||
|
from flask import request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
certFile = "/app/cert/anna_export.crt"
|
||||||
|
pemFile = "/app/cert/anna_export_pass_1234.pem"
|
||||||
|
passwd = "1234"
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
return "Hello, World!"
|
||||||
|
|
||||||
|
@app.route('/sign', methods=['POST'])
|
||||||
|
def create_task():
|
||||||
|
if not request.json or not 'content' in request.json:
|
||||||
|
abort(400)
|
||||||
|
if not os.path.isfile(certFile):
|
||||||
|
return "No crt file exists", 500
|
||||||
|
if not os.path.isfile(pemFile):
|
||||||
|
return "No pem file exists", 500
|
||||||
|
|
||||||
|
temp_name = next(tempfile._get_candidate_names())
|
||||||
|
source_path = os.path.join(tempfile.mkdtemp(), temp_name)
|
||||||
|
result_path = "{}.sgn".format(source_path)
|
||||||
|
|
||||||
|
#logging.warning("request: {}".format(request.json))
|
||||||
|
|
||||||
|
decoded = base64.b64decode(request.json['content'])
|
||||||
|
with open(source_path, 'wb') as output_file:
|
||||||
|
output_file.write(decoded)
|
||||||
|
|
||||||
|
cmd = "openssl smime -sign -signer {} -inkey {} -engine gost -passin pass:{} -binary -noattr -outform DER -in {} -out {}".format(certFile, pemFile, passwd, source_path, result_path)
|
||||||
|
result = os.popen(cmd).read()
|
||||||
|
|
||||||
|
logging.warning('result file path is: {}'.format(result_path))
|
||||||
|
if not os.path.isfile(result_path):
|
||||||
|
return "No result file exists, somthing goes wrong...", 500
|
||||||
|
|
||||||
|
with open(result_path, "rb") as result_file:
|
||||||
|
result_json = base64.b64encode(result_file.read()).decode()
|
||||||
|
os.remove(result_path)
|
||||||
|
|
||||||
|
response = {
|
||||||
|
'signature': result_json
|
||||||
|
}
|
||||||
|
return jsonify(response), 200
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', port=80, debug=True)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
flask
|
||||||
Reference in new issue
Block a user