-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
72 lines (64 loc) · 2.52 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package icertpassage
import (
"context"
"fmt"
"strings"
"unicode/utf16"
dcerpc "github.com/oiweiwei/go-msrpc/dcerpc"
errors "github.com/oiweiwei/go-msrpc/dcerpc/errors"
uuid "github.com/oiweiwei/go-msrpc/midl/uuid"
ndr "github.com/oiweiwei/go-msrpc/ndr"
)
var (
_ = context.Background
_ = fmt.Errorf
_ = utf16.Encode
_ = strings.TrimPrefix
_ = ndr.ZeroString
_ = (*uuid.UUID)(nil)
_ = (*dcerpc.SyntaxID)(nil)
_ = (*errors.Error)(nil)
)
// ICertPassage server interface.
type CertPassageServer interface {
// The CertServerRequest method processes a certificate enrollment request from the
// client.<6>
//
// Return Values: The method MUST return ERROR_SUCCESS (0x00000000) on success. This
// method's return values MUST have identical syntax and semantics to the return values
// specified in [MS-WCCE] section 3.2.1.4.2.1.
//
// If the ADM element Config.CA.Interface.Flags contains the value IF_NORPCICERTREQUEST,
// the server SHOULD return an error.<7>
//
// If the ADM element Config.CA.Interface.Flags contains the value IF_ENFORCEENCRYPTICERTREQUEST
// and the RPC_C_AUTHN_LEVEL_PKT_PRIVACY authentication level ([MS-RPCE] section 2.2.1.1.8)
// is not specified on the RPC connection from the client, the CA MUST refuse to establish
// a connection with the client by returning E_ACCESSDENIED (0x80000009).
//
// Otherwise, the processing rules for the ICertRequestD::Request method ([MS-WCCE]
// section 3.2.2.6.2.1) apply, except that if the ADM element Config.CA.Interface.Flags
// contains the value IF_NOREMOTEICERTREQUEST, these values are ignored and the request
// is processed as though the values were absent.
CertServerRequest(context.Context, *CertServerRequestRequest) (*CertServerRequestResponse, error)
}
func RegisterCertPassageServer(conn dcerpc.Conn, o CertPassageServer, opts ...dcerpc.Option) {
conn.RegisterServer(NewCertPassageServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(CertPassageSyntaxV0_0))...)
}
func NewCertPassageServerHandle(o CertPassageServer) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return CertPassageServerHandle(ctx, o, opNum, r)
}
}
func CertPassageServerHandle(ctx context.Context, o CertPassageServer, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
switch opNum {
case 0: // CertServerRequest
in := &CertServerRequestRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.CertServerRequest(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}