Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
inclavare-containers
提交
9bffcfcb
I
inclavare-containers
项目概览
openanolis
/
inclavare-containers
通知
4
Star
7
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
5
列表
看板
标记
里程碑
合并请求
0
分析
仓库
DevOps
项目成员
Pages
I
inclavare-containers
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
5
Issue
5
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9bffcfcb
编写于
7月 20, 2020
作者:
J
jiazhiguang
提交者:
jia zhang
7月 27, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adapt to occlum 0.14
上级
912cf014
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
26 deletion
+69
-26
shim/config/config.go
shim/config/config.go
+5
-0
shim/runtime/carrier/constants/constants.go
shim/runtime/carrier/constants/constants.go
+7
-0
shim/runtime/signature/server/api/api.go
shim/runtime/signature/server/api/api.go
+2
-1
shim/runtime/signature/server/api/handler.go
shim/runtime/signature/server/api/handler.go
+17
-6
shim/runtime/signature/server/api/server.go
shim/runtime/signature/server/api/server.go
+13
-9
shim/runtime/v2/rune/v2/rune.go
shim/runtime/v2/rune/v2/rune.go
+25
-10
未找到文件。
shim/config/config.go
浏览文件 @
9bffcfcb
...
@@ -4,6 +4,10 @@ type Containerd struct {
...
@@ -4,6 +4,10 @@ type Containerd struct {
Socket
string
`toml:"socket"`
Socket
string
`toml:"socket"`
}
}
type
Signature
struct
{
ServerAddress
string
`toml:"server_address"`
}
type
Occlum
struct
{
type
Occlum
struct
{
BuildImage
string
`toml:"build_image"`
BuildImage
string
`toml:"build_image"`
EnclaveRuntimePath
string
`toml:"enclave_runtime_path"`
EnclaveRuntimePath
string
`toml:"enclave_runtime_path"`
...
@@ -21,5 +25,6 @@ type Config struct {
...
@@ -21,5 +25,6 @@ type Config struct {
LogLevel
string
`toml:"log_level"`
LogLevel
string
`toml:"log_level"`
SgxToolSign
string
`toml:"sgx_tool_sign"`
SgxToolSign
string
`toml:"sgx_tool_sign"`
Containerd
Containerd
`toml:"containerd"`
Containerd
Containerd
`toml:"containerd"`
Signature
Signature
`toml:"signature"`
EnclaveRuntime
EnclaveRuntime
`toml:"enclave_runtime"`
EnclaveRuntime
EnclaveRuntime
`toml:"enclave_runtime"`
}
}
shim/runtime/carrier/constants/constants.go
浏览文件 @
9bffcfcb
...
@@ -169,6 +169,13 @@ function buildUnsignedEnclave(){
...
@@ -169,6 +169,13 @@ function buildUnsignedEnclave(){
/bin/bash ${base_dir}/replace_occlum_image.sh ${rootfs} image
/bin/bash ${base_dir}/replace_occlum_image.sh ${rootfs} image
# occlum build
# occlum build
occlum build
occlum build
if [ ! -f .occlum/build/lib/libocclum-libos.so ]; then
if [ -f .occlum/build/lib/libocclum-libos.so.0 ]; then
pushd .occlum/build/lib/
ln -s libocclum-libos.so.0 libocclum-libos.so
popd
fi
fi
mkdir -p ${rootfs}/${work_dir} || true
mkdir -p ${rootfs}/${work_dir} || true
/bin/cp -fr .occlum ${rootfs}/${work_dir}
/bin/cp -fr .occlum ${rootfs}/${work_dir}
/bin/cp -f Enclave.xml ${rootfs}/${work_dir}
/bin/cp -f Enclave.xml ${rootfs}/${work_dir}
...
...
shim/runtime/signature/server/api/api.go
浏览文件 @
9bffcfcb
...
@@ -18,11 +18,12 @@ func (s *ApiServer) installRoutes() {
...
@@ -18,11 +18,12 @@ func (s *ApiServer) installRoutes() {
{
{
g
.
POST
(
"/pkcs1"
,
s
.
pkcs1Handler
)
g
.
POST
(
"/pkcs1"
,
s
.
pkcs1Handler
)
}
}
r
.
Use
(
loggerHandleFunc
)
.
GET
(
"/api/v1/publickey"
,
s
.
publicKeyHandler
)
}
}
}
}
func
(
s
ApiServer
)
installHealthz
()
{
func
(
s
ApiServer
)
installHealthz
()
{
r
:=
s
.
router
r
:=
s
.
router
r
.
GET
(
"/ping"
,
func
(
c
*
gin
.
Context
)
{
c
.
String
(
http
.
StatusOK
,
"p
o
ng"
)
})
r
.
GET
(
"/ping"
,
func
(
c
*
gin
.
Context
)
{
c
.
String
(
http
.
StatusOK
,
"p
i
ng"
)
})
r
.
GET
(
"/healthz"
,
func
(
c
*
gin
.
Context
)
{
c
.
String
(
http
.
StatusOK
,
"ok"
)
})
r
.
GET
(
"/healthz"
,
func
(
c
*
gin
.
Context
)
{
c
.
String
(
http
.
StatusOK
,
"ok"
)
})
}
}
shim/runtime/signature/server/api/handler.go
浏览文件 @
9bffcfcb
...
@@ -5,8 +5,6 @@ import (
...
@@ -5,8 +5,6 @@ import (
"crypto/rand"
"crypto/rand"
"crypto/rsa"
"crypto/rsa"
"crypto/sha256"
"crypto/sha256"
"crypto/x509"
"encoding/pem"
"io/ioutil"
"io/ioutil"
"net/http"
"net/http"
...
@@ -37,9 +35,22 @@ func (s *ApiServer) pkcs1Handler(c *gin.Context) {
...
@@ -37,9 +35,22 @@ func (s *ApiServer) pkcs1Handler(c *gin.Context) {
}
}
payload
.
Signature
=
string
(
signedBytes
)
payload
.
Signature
=
string
(
signedBytes
)
payload
.
PublicKey
=
string
(
pem
.
EncodeToMemory
(
&
pem
.
Block
{
bytes
,
err
:=
ioutil
.
ReadFile
(
s
.
publicKeyFilePath
)
Type
:
"RSA PUBLIC KEY"
,
if
err
!=
nil
{
Bytes
:
x509
.
MarshalPKCS1PublicKey
(
s
.
publicKey
),
glog
.
Errorf
(
"failed to parse public key, public key path: %s, err:%v"
,
s
.
publicKeyFilePath
,
err
.
Error
())
}))
c
.
AbortWithStatus
(
http
.
StatusInternalServerError
)
return
}
payload
.
PublicKey
=
string
(
bytes
)
c
.
JSON
(
http
.
StatusOK
,
payload
)
c
.
JSON
(
http
.
StatusOK
,
payload
)
}
}
func
(
s
*
ApiServer
)
publicKeyHandler
(
c
*
gin
.
Context
)
{
bytes
,
err
:=
ioutil
.
ReadFile
(
s
.
publicKeyFilePath
)
if
err
!=
nil
{
glog
.
Errorf
(
"failed to parse public key, public key path: %s, err:%v"
,
s
.
publicKeyFilePath
,
err
.
Error
())
c
.
AbortWithStatus
(
http
.
StatusInternalServerError
)
return
}
c
.
JSON
(
http
.
StatusOK
,
string
(
bytes
))
}
shim/runtime/signature/server/api/server.go
浏览文件 @
9bffcfcb
...
@@ -10,11 +10,13 @@ import (
...
@@ -10,11 +10,13 @@ import (
)
)
type
ApiServer
struct
{
type
ApiServer
struct
{
router
*
gin
.
Engine
router
*
gin
.
Engine
listenAddr
string
listenAddr
string
privateKey
*
rsa
.
PrivateKey
privateKey
*
rsa
.
PrivateKey
publicKey
*
rsa
.
PublicKey
publicKey
*
rsa
.
PublicKey
certificate
*
x509
.
Certificate
certificate
*
x509
.
Certificate
publicKeyFilePath
string
privateKeyFilePath
string
}
}
func
NewApiServer
(
listenAddr
string
,
conf
*
conf
.
Config
)
(
*
ApiServer
,
error
)
{
func
NewApiServer
(
listenAddr
string
,
conf
*
conf
.
Config
)
(
*
ApiServer
,
error
)
{
...
@@ -27,10 +29,12 @@ func NewApiServer(listenAddr string, conf *conf.Config) (*ApiServer, error) {
...
@@ -27,10 +29,12 @@ func NewApiServer(listenAddr string, conf *conf.Config) (*ApiServer, error) {
return
nil
,
err
return
nil
,
err
}
}
s
:=
&
ApiServer
{
s
:=
&
ApiServer
{
router
:
gin
.
Default
(),
router
:
gin
.
Default
(),
listenAddr
:
listenAddr
,
listenAddr
:
listenAddr
,
privateKey
:
privateKey
,
privateKey
:
privateKey
,
publicKey
:
publicKey
,
publicKey
:
publicKey
,
publicKeyFilePath
:
conf
.
PublicKeyPath
,
privateKeyFilePath
:
conf
.
PrivateKeyPath
,
}
}
s
.
installRoutes
()
s
.
installRoutes
()
return
s
,
nil
return
s
,
nil
...
...
shim/runtime/v2/rune/v2/rune.go
浏览文件 @
9bffcfcb
package
v2
package
v2
import
(
import
(
"fmt"
"io/ioutil"
"io/ioutil"
"net/url"
"net/url"
"os"
"os"
...
@@ -8,12 +9,13 @@ import (
...
@@ -8,12 +9,13 @@ import (
"path"
"path"
"path/filepath"
"path/filepath"
"github.com/
alibaba/inclavare-containers/shim/runtime/config
"
"github.com/
BurntSushi/toml
"
shim_config
"github.com/alibaba/inclavare-containers/shim/config"
"github.com/alibaba/inclavare-containers/shim/runtime/carrier"
"github.com/alibaba/inclavare-containers/shim/runtime/carrier"
emptycarrier
"github.com/alibaba/inclavare-containers/shim/runtime/carrier/empty"
emptycarrier
"github.com/alibaba/inclavare-containers/shim/runtime/carrier/empty"
"github.com/alibaba/inclavare-containers/shim/runtime/carrier/graphene"
"github.com/alibaba/inclavare-containers/shim/runtime/carrier/graphene"
"github.com/alibaba/inclavare-containers/shim/runtime/carrier/occlum"
"github.com/alibaba/inclavare-containers/shim/runtime/carrier/occlum"
"github.com/alibaba/inclavare-containers/shim/runtime/config"
signclient
"github.com/alibaba/inclavare-containers/shim/runtime/signature/client"
signclient
"github.com/alibaba/inclavare-containers/shim/runtime/signature/client"
"github.com/alibaba/inclavare-containers/shim/runtime/v2/rune"
"github.com/alibaba/inclavare-containers/shim/runtime/v2/rune"
"github.com/alibaba/inclavare-containers/shim/runtime/v2/rune/constants"
"github.com/alibaba/inclavare-containers/shim/runtime/v2/rune/constants"
...
@@ -86,19 +88,32 @@ func (s *service) carrierMain(req *taskAPI.CreateTaskRequest) (carrier.Carrier,
...
@@ -86,19 +88,32 @@ func (s *service) carrierMain(req *taskAPI.CreateTaskRequest) (carrier.Carrier,
var
signatureFile
string
var
signatureFile
string
if
carrierKind
!=
rune
.
Empty
{
if
carrierKind
!=
rune
.
Empty
{
//TODO: Retry on failture.
//TODO: Retry on failture.
/*publicKey, signature, err := remoteSign("https://10.0.8.126:8443/api/v1/signature", commonArgs.Enclave)
var
cfg
shim_config
.
Config
defer os.RemoveAll(path.Dir(publicKey))*/
var
publicKey
,
signature
string
//FIXME mock signature
if
_
,
err
:=
toml
.
DecodeFile
(
constants
.
ConfigurationPath
,
&
cfg
);
err
!=
nil
{
return
carr
,
err
}
materialRealPath
:=
signingMaterial
materialRealPath
:=
signingMaterial
if
carrierKind
==
rune
.
Occlum
{
if
carrierKind
==
rune
.
Occlum
{
materialRealPath
=
filepath
.
Join
(
req
.
Bundle
,
signingMaterial
)
materialRealPath
=
filepath
.
Join
(
req
.
Bundle
,
signingMaterial
)
}
}
publicKey
,
signature
,
err
:=
mockSign
(
materialRealPath
)
if
cfg
.
Signature
.
ServerAddress
==
""
{
if
err
!=
nil
{
publicKey
,
signature
,
err
=
mockSign
(
materialRealPath
)
logrus
.
Errorf
(
"carrierMain: mock sign failed. error: %++v"
,
err
)
if
err
!=
nil
{
return
carr
,
err
logrus
.
Errorf
(
"carrierMain: mock sign failed. error: %++v"
,
err
)
return
carr
,
err
}
defer
os
.
RemoveAll
(
path
.
Dir
(
publicKey
))
}
else
{
publicKey
,
signature
,
err
=
remoteSign
(
fmt
.
Sprintf
(
"%s/api/v1/signature"
,
cfg
.
Signature
.
ServerAddress
),
materialRealPath
)
if
err
!=
nil
{
logrus
.
Errorf
(
"carrierMain: get signature failed. server address: %s. error: %++v"
,
cfg
.
Signature
.
ServerAddress
,
err
)
return
carr
,
err
}
defer
os
.
RemoveAll
(
path
.
Dir
(
publicKey
))
}
}
defer
os
.
RemoveAll
(
path
.
Dir
(
publicKey
))
commonArgs
.
Key
=
publicKey
commonArgs
.
Key
=
publicKey
signatureFile
=
signature
signatureFile
=
signature
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录