使用Golang读取pfx格式证书里面的私钥,用RSA算法签名数据。
代码如下:
```go
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"log"
"os"
pkcs12 "software.sslmate.com/src/go-pkcs12"
)
func main() {
rsaSingFromPfxKey()
}
func rsaSingFromPfxKey() {
data := "测试数据"
// 读取pfx私钥
certPath := "./20190801.3300000002925831.pfx"
certBytes, err := os.ReadFile(certPath)
if err != nil {
log.Fatal(err)
}
pkey, _, _ := pkcs12.Decode(certBytes,...
```nginx
server {
location / {
proxy_buffering off;
proxy_http_version 1.1;
proxy_read_timeout 36000s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
if ($subdomain = "plex") {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
...
激活步骤:
1. 下载安装原版Navicat
2. 下载附件文件,替换文件
3. 可选步骤,删除注册表项:`HKEY_CURRENT_USER\Software\PremiumSoft\NavicatPremium\Registration16XEN\`
附件:
链接: https://pan.baidu.com/s/1RqMEroA_gmdm90DG9rjPxA?pwd=an3n
提取码: `an3n`...
Ubuntu如何开启或关闭Wayland? 1、编辑文件`sudo nano /etc/gdm3/custom.conf` 开启:`WaylandEnable=true` 关闭:`WaylandEnable=false` 2、登出,在登录也就选择会话类型...
Ubuntu 23.10在10月13号发布了正式版本,发布后出现了一个小插曲,修正了一下。到今天25号了,用命令sudo do-release-upgrade检测新版本还是显示未找到新版本,这是什么原因呢?我们可以看这个链接的内容https://changelogs.ubuntu.com/meta-release看看里面有没有23.10,如果没有那是检查不到更新的。这时如果需要升级可以加上-d参数,通过开发版通道来升级,版本也正式版是一样的。 ...
可观测性主要包括三个方面:追踪(traces)、指标(metrics)和日志(logs)。
OpenTelemetry 的指标功能还是测试状态,没有实现日志的功能,日志可以用其他流行的日志库记录,然后收集到类似ELK的日志系统里面。
追踪数据存储后端是用`jaeger`,指标数据存储后端是用`prometheus`。
前面几个文章实现的是追踪,本文主要讲一下指标。
指标数据直接用`prometheus`的go客户端生成也是一样的,不一定需要用`OpenTelemetry`提供的库。
`OpenTelemetry`的方式是先创建`exporter`和`provider`,之后就可以生成指标了,`main.go`:
```go
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/otel/attribute"
p...
[上一篇文章](https://360us.net/article/87.html)用的是http协议做服务间的调用协议,这篇改成gRPC。
首先安装包`otelgrpc`:
```shell
go get go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
```
创建一个`api`目录,创建`rpc.proto`文件:
```protobuf
syntax = "proto3";
package api;
// advanced目录执行编译: protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative api/rpc.proto
option go_package ="github.com/ilaziness/gopkg/opentelemetry/as/api";
service AsRp...
从上一篇入门:[https://www.360us.net/article/86.html](https://www.360us.net/article/86.html)我们知道用OpenTelemetry实现应用的可观测性需要三个部分:
- `exporter`:负责遥测数据输出,可以输出到控制台,文件,后端存储或者中间的收集节点服务器。
- `instrumentation `:这个部分就是产生追踪数据,也就是创建`span`。
- `TracerProvider`:扮演了中间角色,把生成的遥测数据输出到`exporter`。
目前Go是不支持自动追踪的,一些公共库可以在这里https://opentelemetry.io/ecosystem/registry/?language=go 找到封装好的追踪代码。
比如`otelhttp`是对`net/http`的包装,还有`gin`,`gRPC`的等等,自己的私有库、包、或者函数就需要自己手动添加代码了。
本文的内容是实现在多个服务之间的追踪。
创建三个服务,分别是`main`、`as sevice`...
> 本文定位是快速入门,理解OpenTelemetry在go里面的基本使用
>
> 参考文档:https://opentelemetry.io/docs/instrumentation/go/getting-started
Go 版本需要是1.16以上。
创建一个名字是`fib`的go项目,就一个功能计算斐波那契数列。
创建三个文件:
`fib.go`测试项目的核心,功能是计算斐波那契数列。
```go
package main
import "fmt"
// Fibonacci 计算斐波那契数
func Fibonacci(n uint) (uint64, error) {
if n ...
按照官方文档里面React的集成方法做,从其他页面跳转到编辑器页面是没有问题的,但是你要点击刷新按钮刷新整个编辑器所在页面时就会报错了:`ReferenceError: self is not defined`
本文解决的是这个问题。
新增文件`components/Editor.jsx`:
```jsx
import React, { useEffect, useRef } from "react";
const editorCfg = {
language: 'zh-cn'
}
function Editor({ onChange, editorLoaded, name, data }) {
const editorRef = useRef();
const { CKEditor, ClassicEditor } = editorRef.current || {};
useEffect(() => {
editorRef.current = {
CKEditor...