-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LAPI registration by agents don't support TLS skip verify #213
Comments
@erwanval: Thanks for opening an issue, it is currently awaiting triage. If you haven't already, please provide the following information:
In the meantime, you can:
DetailsI am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the forked project rr404/oss-governance-bot repository. |
@erwanval: There are no 'kind' label on this issue. You need a 'kind' label to start the triage process.
DetailsI am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the forked project rr404/oss-governance-bot repository. |
/kind bug |
Hi @erwanval ,
|
I'm not sure I understand why this condition exists, but it looks like the init containers register the agent only if Anyway, that's not my case here. I have only TLS enabled, not mTLS (so {{- if or (not .Values.tls.enabled) (not .Values.tls.agent.tlsClientAuth) }}
volumeMounts:
- name: crowdsec-config
mountPath: /tmp_config
env:
- name: REGISTRATION_TOKEN
valueFrom:
secretKeyRef:
name: crowdsec-lapi-secrets
key: registrationToken
- name: USERNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: LAPI_URL
value: http://{{ .Release.Name }}-service.{{ .Release.Namespace }}:8080
- name: LAPI_HOST
value: "{{ .Release.Name }}-service.{{ .Release.Namespace }}"
- name: LAPI_PORT
value: "8080"
{{- end }} If - name: LAPI_URL
value: {{ ternary "https" "http" .Values.tls.enabled }}://{{ .Release.Name }}-service.{{ .Release.Namespace }}:8080 But my main issue is that it doesn't account for Here are the values.yaml I tested with (simplified & anonymized) anyway: container_runtime: containerd
config:
config.yaml.local: |
db_config:
type: postgresql
user: crowdsecuser
password: ${DB_PASSWORD}
db_name: crowdsecdb
host: 192.168.0.1
port: 1234
sslmode: require
secrets:
username: crowdsec-agent
password: password
tls:
enabled: true
caBundle: false
insecureSkipVerify: true
certManager:
duration: 2160h0m0s # 90d
renewBefore: 360h0m0s # 15d
issuerRef:
name: cluster-internal-ca
kind: ClusterIssuer
secretTemplate:
annotations:
reloader.stakater.com/match: "true"
agent:
tlsClientAuth: false
agent:
resources:
requests:
cpu: 10m
memory: 100Mi
limits:
cpu: null
memory: 100Mi
metrics:
enabled: true
serviceMonitor:
enabled: true
acquisition:
- namespace: ingress-nginx
podName: ingress-nginx-controller-*
program: nginx
env:
- name: PARSERS
value: "crowdsecurity/cri-logs"
- name: COLLECTIONS
value: "crowdsecurity/nginx crowdsecurity/whitelist-good-actors"
- name: LEVEL_DEBUG
value: "false"
lapi:
resources:
requests:
cpu: 10m
memory: 100Mi
limits:
cpu: null
memory: 100Mi
strategy:
type: RollingUpdate
metrics:
enabled: true
serviceMonitor:
enabled: true
env:
- name: BOUNCER_KEY_CLUSTER_NGINX_INGRESS
valueFrom:
secretKeyRef:
name: crowdsec-lapi-secrets
key: bouncerApiKey
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: crowdsec-lapi-secrets
key: dbPassword
secrets:
csLapiSecret: cslapisecret
extraSecrets:
dbPassword: dbpass
bouncerApiKey: bouncerkey
persistentVolume:
config:
enabled: false
data:
enabled: false
replicas: 2
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
k8s-app: crowdsec
type: lapi
topologyKey: topology.kubernetes.io/zone
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
k8s-app: crowdsec
type: lapi
topologyKey: kubernetes.io/hostname
topologySpreadConstraints:
- labelSelector:
matchLabels:
k8s-app: crowdsec
type: lapi
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway |
@erwanval thanks for the detailed reply, I'll add a detailed one a bit later this evening. For now, why not set |
Currently, the helmchart supports two authentication methods between the agent and the LAPI:
Password authentication is removed in favor of auto-registration, as both auto-registration and TLS authentication allow for easy scaling of the agents and can be used to create agents with meaningful names in the LAPI.
Registering of the agent is only done when
This is not a supported scenario, as this leads to the LAPI only supporting https, while (as you've identified correctly), the cscli lapi register is not working. Passing environment variables like USE_TLS, INSECURE_SKIP_VERIFY don't resolve that, which is why they are not passed to the init container. My main conclusion is that the documentation should be adjusted so that both authentication methods are explained better. |
I only use TLS to cipher cluster internal traffic. Certificate validity itself is not really a concern in my case, and allows to ignore other issues that would arise otherwise, such as cert renewal (which is not handled by this chart, updating certs requires a restart of crowdsec pods). By enabling client auth through TLS, certificate validity becomes a requirement. It would makes no sense to have both client auth and skip verify enabled, as it's the same as having no auth at all, not even a registration token. And short lived self signed certificate will cause issues during renewal in that case (which could be solved by relying on other tools, but still add complexity).
In my opinion, TLS only (no client auth) should be supported by |
Makes sense. I think your requirement of using TLS without TLS client auth can be accommodated with either:
I don't know if the first is feasible and it's probably something for the crowdsec component itself, not this chart. Maybe @LaurenceJJones can comment on that. |
Following a recent update, crowdsec agent are now registering to the LAPI using an API call performed through the cscli.
However, when TLS is enabled for LAPI, this registration fails with the following error, because the init container has the LAPI url hardcoded:
But even if we change the LAPI_URL to https, it still fails with another error, because the certificate cannot be verified:
I have tried to set an env variable named
INSECURE_SKIP_VERIFY
for the init container, similar to how it's done for the agent container, but it doesn't work.As far as I can tell, there is no option for
cscli lapi register
to skip certificate verify. Thus, the agent cannot start when LAPI is deployed using TLS with a certificate signed by a custom CA or self signed (which is what the chart install by default iftls.enabled: true
).The text was updated successfully, but these errors were encountered: